Closed emnvn closed 8 years ago
Hi @emnvn,
All looks correct at first glance. Could you trace the mod_auth_token
and send as the captured trace?
Hello @michalwski ,
I enable DEBUG LOG but I can't see anny error. I run MongooseIM on a VirtualBox CentOS 6.4. Can you remote to my computer to check log ? This is my full debug logs:
(mongooseim@localhost)2> 2016-08-17 00:23:14.689 [debug] <0.693.0>@mod_websockets:websocket_handle:182 Received: <<"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi8yRjM2ODM2QzVEQ0ExMjMxMTQ3MTM2ODE1ODQ3MTk0NgA2MzYzODU5MDk2NQBiOGE0NDUyZDdmYjU2ZmIzMzU4NWI2ODQyZDg0OTE3OWU2ZjAxNzIxMzEyZDE1ZGFjMmNjMDI2NWZlMDdjN2ZkMTg1YzE2ZDI3YmZlNjU2MmM0Yzc0NjdhM2FkNTgzMTk=</auth>">>
2016-08-17 00:23:14.690 [debug] <0.693.0>@mod_websockets:handle_text:247 handle_text2 Text: <<"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi8yRjM2ODM2QzVEQ0ExMjMxMTQ3MTM2ODE1ODQ3MTk0NgA2MzYzODU5MDk2NQBiOGE0NDUyZDdmYjU2ZmIzMzU4NWI2ODQyZDg0OTE3OWU2ZjAxNzIxMzEyZDE1ZGFjMmNjMDI2NWZlMDdjN2ZkMTg1YzE2ZDI3YmZlNjU2MmM0Yzc0NjdhM2FkNTgzMTk=</auth>">>, Req: {http_req,#Port<0.5909>,ranch_tcp,keepalive,<0.693.0>,<<"GET">>,'HTTP/1.1',{{10,32,52,247},60538},<<"10.32.52.156">>,undefined,5280,<<"/ws-xmpp/">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"10.32.52.156:5280">>},{<<"user-agent">>,<<"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>},{<<"accept-language">>,<<"en-US,en;q=0.5">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost">>},{<<"sec-websocket-protocol">>,<<"xmpp">>},{<<"sec-websocket-extensions">>,<<"permessage-deflate">>},{<<"sec-websocket-key">>,<<"whheyqcxzZ4+4htjwQqXWA==">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"sec-websocket-extensions">>,[{<<"permessage-deflate">>,[]}]},{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_version,13},{websocket_compress,false}],waiting,<<>>,undefined,false,done,[],<<>>,undefined}, State: {ws_state,<0.696.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-17 00:23:14.690 [debug] <0.693.0>@mod_websockets:handle_text:250 handle_text2 NewParser: {parser,<<>>,{config,true,true},[]}, Elements: [{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi8yRjM2ODM2QzVEQ0ExMjMxMTQ3MTM2ODE1ODQ3MTk0NgA2MzYzODU5MDk2NQBiOGE0NDUyZDdmYjU2ZmIzMzU4NWI2ODQyZDg0OTE3OWU2ZjAxNzIxMzEyZDE1ZGFjMmNjMDI2NWZlMDdjN2ZkMTg1YzE2ZDI3YmZlNjU2MmM0Yzc0NjdhM2FkNTgzMTk=">>}]}], State1: {ws_state,<0.696.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-17 00:23:14.690 [debug] <0.693.0>@mod_websockets:handle_text:253 case maybe_start_fsm: Req1 {http_req,#Port<0.5909>,ranch_tcp,keepalive,<0.693.0>,<<"GET">>,'HTTP/1.1',{{10,32,52,247},60538},<<"10.32.52.156">>,undefined,5280,<<"/ws-xmpp/">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"10.32.52.156:5280">>},{<<"user-agent">>,<<"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>},{<<"accept-language">>,<<"en-US,en;q=0.5">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost">>},{<<"sec-websocket-protocol">>,<<"xmpp">>},{<<"sec-websocket-extensions">>,<<"permessage-deflate">>},{<<"sec-websocket-key">>,<<"whheyqcxzZ4+4htjwQqXWA==">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"sec-websocket-extensions">>,[{<<"permessage-deflate">>,[]}]},{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_version,13},{websocket_compress,false}],waiting,<<>>,undefined,false,done,[],<<>>,undefined}, State2: {ws_state,<0.696.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-17 00:23:14.690 [debug] <0.693.0>@mod_websockets:process_client_stream_start:366 EMNVN process_client_stream_start 0 OpenTag: open Elements: [{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi8yRjM2ODM2QzVEQ0ExMjMxMTQ3MTM2ODE1ODQ3MTk0NgA2MzYzODU5MDk2NQBiOGE0NDUyZDdmYjU2ZmIzMzU4NWI2ODQyZDg0OTE3OWU2ZjAxNzIxMzEyZDE1ZGFjMmNjMDI2NWZlMDdjN2ZkMTg1YzE2ZDI3YmZlNjU2MmM0Yzc0NjdhM2FkNTgzMTk=">>}]}]
2016-08-17 00:23:14.690 [debug] <0.693.0>@mod_websockets:send_to_fsm:269 EMNVN send_to_fsm FSM: <0.696.0>, StreamElement: {xmlstreamelement,{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi8yRjM2ODM2QzVEQ0ExMjMxMTQ3MTM2ODE1ODQ3MTk0NgA2MzYzODU5MDk2NQBiOGE0NDUyZDdmYjU2ZmIzMzU4NWI2ODQyZDg0OTE3OWU2ZjAxNzIxMzEyZDE1ZGFjMmNjMDI2NWZlMDdjN2ZkMTg1YzE2ZDI3YmZlNjU2MmM0Yzc0NjdhM2FkNTgzMTk=">>}]}}
Thanks for your help.
I was referring to the Erlang dbg. Let's make it ass simple as possible. Could you do the following?
Connect to MongooseIM node:
mongoseim debg
Run the command (mind the ending dot .
)
recon_trace:calls({mod_auth_token, '_', fun(_) -> return_trace() end}, 100).
This should return number grater than 0.
Hi @michalwski,
I have execute there your steps:
14:3:05.295091 <0.1193.0> mod_auth_token:process_iq({jid,<<"test01">>,<<"dtsc.com.vn">>,<<"6E8B7ED679985E941471503772393947">>,
<<"test01">>,<<"dtsc.com.vn">>,<<"6E8B7ED679985E941471503772393947">>}, {jid,<<"test01">>,<<"dtsc.com.vn">>,<<>>,<<"test01">>,<<"dtsc.com.vn">>,<<>>}, {iq,<<"f4504073-6774-4976-8436-99c09cc1e6b0:sendIQ">>,get,
<<"erlang-solutions.com:xmpp:token-auth:0">>,<<>>,
{xmlel,<<"query">>,
[{<<"xmlns">>,<<"erlang-solutions.com:xmpp:token-auth:0">>}],
[]}})
14:3:05.384769 <0.1193.0> mod_auth_token:process_iq/3 --> {iq,
<<"f4504073-6774-4976-8436-99c09cc1e6b0:sendIQ">>,
result,
<<"erlang-solutions.com:xmpp:token-auth:0">>,
<<>>,
[{xmlel,
<<"items">>,
[{<<"xmlns">>,
<<"erlang-solutions.com:xmpp:token-auth:0">>}],
[{xmlel,
<<"access_token">>,
[{<<"xmlns">>,
<<"erlang-solutions.com:xmpp:token-auth:0">>}],
[{xmlcdata,
<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=">>}]},
{xmlel,
<<"refresh_token">>,
[{<<"xmlns">>,
<<"erlang-solutions.com:xmpp:token-auth:0">>}],
[{xmlcdata,
<<"cmVmcmVzaAB0ZXN0MDFAZHRzYy5jb20udm4vNkU4QjdFRDY3OTk4NUU5NDE0NzE1MDM3NzIzOTM5NDcANjM2Mzg4MDkzODUAMQA4ZTA4Zjk2NGFkMjY3YTA3ZDNmZjg0OGFhNzQ2NjdkNzQ5NWJlZTFiZjE3ZDZmNTA1NDFiNzMyY2I4MDZhYWVhZTdjNDU1NzNjODMyNTM2YTYzOWUxY2VkMWFiMjRjNzM=">>}]}]}]}
(mongooseim@localhost)2>
When I try to authenticate with token, I can't see any log in console. But If I attach from mongoose sesession I can see logs which is similar to logs that I have pasted in the issue:
(mongooseim@localhost)2> 2016-08-18 14:04:58.238 [debug] <0.1192.0>@mod_websockets:websocket_handle:182 Received: <<"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=</auth>">>
2016-08-18 14:04:58.239 [debug] <0.1192.0>@mod_websockets:handle_text:247 handle_text2 Text: <<"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=</auth>">>, Req: {http_req,#Port<0.6927>,ranch_tcp,keepalive,<0.1192.0>,<<"GET">>,'HTTP/1.1',{{10,12,10,140},54290},<<"10.12.10.89">>,undefined,5280,<<"/ws-xmpp/">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"10.12.10.89:5280">>},{<<"user-agent">>,<<"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>},{<<"accept-language">>,<<"en-US,en;q=0.5">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost">>},{<<"sec-websocket-protocol">>,<<"xmpp">>},{<<"sec-websocket-extensions">>,<<"permessage-deflate">>},{<<"sec-websocket-key">>,<<"RpfKWo65pp/Ad2ak1ovTow==">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"sec-websocket-extensions">>,[{<<"permessage-deflate">>,[]}]},{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_version,13},{websocket_compress,false}],waiting,<<>>,undefined,false,done,[],<<>>,undefined}, State: {ws_state,<0.1193.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-18 14:04:58.240 [debug] <0.1192.0>@mod_websockets:handle_text:250 handle_text2 NewParser: {parser,<<>>,{config,true,true},[]}, Elements: [{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=">>}]}], State1: {ws_state,<0.1193.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-18 14:04:58.241 [debug] <0.1192.0>@mod_websockets:handle_text:253 case maybe_start_fsm: Req1 {http_req,#Port<0.6927>,ranch_tcp,keepalive,<0.1192.0>,<<"GET">>,'HTTP/1.1',{{10,12,10,140},54290},<<"10.12.10.89">>,undefined,5280,<<"/ws-xmpp/">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"10.12.10.89:5280">>},{<<"user-agent">>,<<"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>},{<<"accept-language">>,<<"en-US,en;q=0.5">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost">>},{<<"sec-websocket-protocol">>,<<"xmpp">>},{<<"sec-websocket-extensions">>,<<"permessage-deflate">>},{<<"sec-websocket-key">>,<<"RpfKWo65pp/Ad2ak1ovTow==">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"sec-websocket-extensions">>,[{<<"permessage-deflate">>,[]}]},{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_version,13},{websocket_compress,false}],waiting,<<>>,undefined,false,done,[],<<>>,undefined}, State2: {ws_state,<0.1193.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-18 14:04:58.243 [debug] <0.1192.0>@mod_websockets:process_client_stream_start:366 EMNVN process_client_stream_start 0 OpenTag: open Elements: [{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=">>}]}]
2016-08-18 14:04:58.243 [debug] <0.1192.0>@mod_websockets:send_to_fsm:269 EMNVN send_to_fsm FSM: <0.1193.0>, StreamElement: {xmlstreamelement,{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=">>}]}}
Hope that you can show me the problems, Thanks.
Thanks @emnvn, that helps. I need you to trace module cyrsasl_oauth
(similar steps as before, just change the recon_trace:calls
accordingly) which is responsible for the token auth method. In the end it should call mod_auth_token
to check the provided token but I don't see this in the trace you provided.
Also, it would be very helpful if you could provide all the WebSocket packets your client app sends to the server in your test.
Hello @michalwski,
First Thanks for your response soon. I have make steps as you described but I can't see any log which relate to cyrsasl_oauth.
After run recon_trace:calls with cyrsasl_oauth I saw the response number of "6"
I have attached the wireshark capture files where 10.12.10.140 is my xmpp client IP 10.12.10.89 is my xmpp server IP
Thanks very much for your help! mod_auth_token_trace.zip
Hi @ludwikbukowski ,
Do you know what is the root cause ?
Thanks!
@emnvn yes, you have to reset stream before authentication with token. You cannot authenticate when you're already logged in :)
Hello @ludwikbukowski,
I have used strophejs as a websocket client I have tried these options but the result is still the problem:
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi9GQ0NCODJEQTZDQkNGQTBEMTQ3MTQzMjQ3NjEzNDgyADYzNjM4NjU1MjgyAGQyYWZmM2I0MjE1NjkzZjBmMTllMTIwN2FiMDA5YTVmOTM3OTBlMDY0MTgxN2RiZjY5MmZlN2UwMWVkODcwNDk3ZmVlNWRmYWE4OGM3Y2I4ZDc4Njk2MTY0NjYyNDhmNw==</auth>
The result still the same, server don't response any message.
Thanks &Best regards.
Can you provide me more Mongooseim logs? e.g logs from whole session, not only when the <auth>
stanza is sent?
Hi @ludwikbukowski,
I can only see these logs
(mongooseim@localhost)2> 2016-08-18 14:04:58.238 [debug] <0.1192.0>@mod_websockets:websocket_handle:182 Received: <<"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=</auth>">>
2016-08-18 14:04:58.239 [debug] <0.1192.0>@mod_websockets:handle_text:247 handle_text2 Text: <<"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=</auth>">>, Req: {http_req,#Port<0.6927>,ranch_tcp,keepalive,<0.1192.0>,<<"GET">>,'HTTP/1.1',{{10,12,10,140},54290},<<"10.12.10.89">>,undefined,5280,<<"/ws-xmpp/">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"10.12.10.89:5280">>},{<<"user-agent">>,<<"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>},{<<"accept-language">>,<<"en-US,en;q=0.5">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost">>},{<<"sec-websocket-protocol">>,<<"xmpp">>},{<<"sec-websocket-extensions">>,<<"permessage-deflate">>},{<<"sec-websocket-key">>,<<"RpfKWo65pp/Ad2ak1ovTow==">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"sec-websocket-extensions">>,[{<<"permessage-deflate">>,[]}]},{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_version,13},{websocket_compress,false}],waiting,<<>>,undefined,false,done,[],<<>>,undefined}, State: {ws_state,<0.1193.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-18 14:04:58.240 [debug] <0.1192.0>@mod_websockets:handle_text:250 handle_text2 NewParser: {parser,<<>>,{config,true,true},[]}, Elements: [{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=">>}]}], State1: {ws_state,<0.1193.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-18 14:04:58.241 [debug] <0.1192.0>@mod_websockets:handle_text:253 case maybe_start_fsm: Req1 {http_req,#Port<0.6927>,ranch_tcp,keepalive,<0.1192.0>,<<"GET">>,'HTTP/1.1',{{10,12,10,140},54290},<<"10.12.10.89">>,undefined,5280,<<"/ws-xmpp/">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"10.12.10.89:5280">>},{<<"user-agent">>,<<"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>},{<<"accept-language">>,<<"en-US,en;q=0.5">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost">>},{<<"sec-websocket-protocol">>,<<"xmpp">>},{<<"sec-websocket-extensions">>,<<"permessage-deflate">>},{<<"sec-websocket-key">>,<<"RpfKWo65pp/Ad2ak1ovTow==">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"sec-websocket-extensions">>,[{<<"permessage-deflate">>,[]}]},{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_version,13},{websocket_compress,false}],waiting,<<>>,undefined,false,done,[],<<>>,undefined}, State2: {ws_state,<0.1193.0>,open,{parser,<<>>,{config,true,true},[]},[],none}
2016-08-18 14:04:58.243 [debug] <0.1192.0>@mod_websockets:process_client_stream_start:366 EMNVN process_client_stream_start 0 OpenTag: open Elements: [{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=">>}]}]
2016-08-18 14:04:58.243 [debug] <0.1192.0>@mod_websockets:send_to_fsm:269 EMNVN send_to_fsm FSM: <0.1193.0>, StreamElement: {xmlstreamelement,{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"X-OAUTH">>}],[{xmlcdata,<<"YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi82RThCN0VENjc5OTg1RTk0MTQ3MTUwMzc3MjM5Mzk0NwA2MzYzODcyNjU4NQA4MThhODcxMGVhNzlmMGZlYTQ1YWZkNjE5MjA5MDMxN2ZhNDM4YjY5Y2M0NDA4MTMyYTY4YmM4MGFiOWE2ZmExOGNmMGU0NGM1OGQ4MDRmZGE0MzBjNjQwZTgxYTc3N2I=">>}]}}
It if is not enough, can you show me how to see those logs ?
Thanks.
just before websocket_handle:182 Received: <<"<auth (...)
log you should be able to see following line:
[debug] <0.1157.0>@mod_websockets:websocket_handle:182 Received: <<"<open xmlns='urn:ietf:params:xml:ns:xmpp-framing' to='localhost' version='1.0'/>">>
If you don't have it it means that your client didn't reset the stream. Basically, the scenario for acquiring the access token and authentication with it should look like:
(client already connected)
Client:
<iq to='geralt_s@localhost' type='get' id='1bdc3eb1f89e28810f93b147e4870a90'>
<query xmlns='erlang-solutions.com:xmpp:token-auth:0'/>
</iq>
Server:
<iq from='geralt_s@localhost' to='geralt_s@localhost/res'
id='55850c43-e9e7-4508-b4e6-fc10a40f4c8b:sendIQ' type='result' xmlns='jabber:client'>
<items xmlns='erlang-solutions.com:xmpp:token-auth:0'>
<access_token xmlns='erlang-solutions.com:xmpp:token-auth:0'>
YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi84N0IwRUE3RjFCRUUwN0MwMTQ2OTc3ODQ4NDMxNDYxOAA2MzYzNzAwMzQ1MQAwMmRlYzM0MTQyNzczOTY5ZTFlMjQzOGM2OGNhZDA4MGVjZjMzMjViNTIzOTZkMmE0YTU0ZjMyNDJlNmJhZjRlZTUzMTI2NDc3NWM5MWM0MmViMTNmMTRjOTQ3ZDhlOTM=
</access_token>
<refresh_token xmlns='erlang-solutions.com:xmpp:token-auth:0'>
cmVmcmVzaAB0ZXN0MDFAZHRzYy5jb20udm4vODdCMEVBN0YxQkVFMDdDMDE0Njk3Nzg0ODQzMTQ2MTgANjM2MzcwODYyNTEAMQBiOTE2NGUwNDc1MGExNDFlZTVlZjVhNWJjNGFmZmU3ODc2Mzc4MzFiZDY1MmZiYjZjMjE4NWU4ZGM5OWU0NjI2ZDdhNzJkODA2YWNlYjU4OGY0NTY5ZTE4OWVkZmY3Y2U=
> </refresh_token>
</items>
</iq>
C:
<close xmlns='urn:ietf:params:xml:ns:xmpp-framing'/>
S:
<close xmlns='urn:ietf:params:xml:ns:xmpp-framing'/>
(now client reset the websocket stream)
C:
<open xmlns='urn:ietf:params:xml:ns:xmpp-framing' to='localhost' version='1.0'/>
S:
<open version='1.0' xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-framing'
id='839F0854209050BC' from='localhost'/>
S:
<features xmlns='http://etherx.jabber.org/streams'>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>PLAIN</mechanism>
<mechanism>X-OAUTH</mechanism>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>SCRAM-SHA-1</mechanism>
</mechanisms>
<register xmlns='http://jabber.org/features/iq-register'/>
<sm xmlns='urn:xmpp:sm:3'/>
</features>
C:
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi9GQ0NCODJEQTZDQkNGQTBEMTQ3MTQzMjQ3NjEzNDgyADYzNjM4NjU1MjgyAGQyYWZmM2I0MjE1NjkzZjBmMTllMTIwN2FiMDA5YTVmOTM3OTBlMDY0MTgxN2RiZjY5MmZlN2UwMWVkODcwNDk3ZmVlNWRmYWE4OGM3Y2I4ZDc4Njk2MTY0NjYyNDhmNw==</auth>
S:
<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
Hi @ludwikbukowski,
I have tested with your flow, Token Authen work now. But there is some issues which related it, I will try to solve it.
Thanks @ludwikbukowski and @michalwski for your help.
Best Regards,
@emnvn I'm glad that you managed it, if you have any other questions, do not hesitate to ask here! if not, please close the issue.
Hi all, I have a problem after authorization. I have a feeling that I'm doing something wrong, if you can, please help sort it out. So, after authorization
C:
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi9GQ0NCODJEQTZDQkNGQTBEMTQ3MTQzMjQ3NjEzNDgyADYzNjM4NjU1MjgyAGQyYWZmM2I0MjE1NjkzZjBmMTllMTIwN2FiMDA5YTVmOTM3OTBlMDY0MTgxN2RiZjY5MmZlN2UwMWVkODcwNDk3ZmVlNWRmYWE4OGM3Y2I4ZDc4Njk2MTY0NjYyNDhmNw==</auth>
S:
<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
When I try send any other XML packet, by eg: message, I get second response
S:
<error xmlns='http://etherx.jabber.org/streams'><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></error>
After some investigation I see that my package always falls into ejabberd_c2s:wait_for_stream/2
...
wait_for_stream({xmlstreamelement, _S}, StateData) ->
c2s_stream_error(?INVALID_XML_ERR, StateData);
...
But I don't understand why... please help me with this problem, thanks!
Hi @vkatsuba
Please do not resurrect old, closed issues. :) Please open a new ticket for your problem.
Hi @fenek, I see, sorry for this. I created a new ticket https://github.com/esl/MongooseIM/issues/1840 Regards
MongooseIM version: 2.0.0-beta1 Installed from: source Erlang/OTP version: Erlang/OTP 17 [erts-6.4] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
I have tried to use access token and refresh token to authenticate to XMPP server. After login by user/pass I requested this pair of token by seeing this xml stanza
Then I use the access token to authenticate with xmpp server, I sent this xml stanza
But I can't receive any response from xmpp server. I saw this message which is received by xmpp server.
2016-08-10 09:39:29.439 [debug] <0.686.0>@mod_websockets:websocket_handle:182 Received: <<"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH'>YWNjZXNzAHRlc3QwMUBkdHNjLmNvbS52bi84N0IwRUE3RjFCRUUwN0MwMTQ2OTc3ODQ4NDMxNDYxOAA2MzYzNzAwMzQ1MQAwMmRlYzM0MTQyNzczOTY5ZTFlMjQzOGM2OGNhZDA4MGVjZjMzMjViNTIzOTZkMmE0YTU0ZjMyNDJlNmJhZjRlZTUzMTI2NDc3NWM5MWM0MmViMTNmMTRjOTQ3ZDhlOTM=</auth>">>
This is my config file
I don't know what is my mistake ? Hope that someone can help me.
Thanks.