rabbitmq / rabbitmq-oauth2-tutorial

Explore integration of RabbitMQ with Oauth 2.0 auth backend plugin
42 stars 23 forks source link

Configuration not working on RabbitMQ 3.8.2 #2

Closed peykens closed 2 years ago

peykens commented 4 years ago

Hi,

I'm very interested in getting this plugin working on RabbitMQ 3.8.2, but I'm facing some config issues. The rabbitmq.config doesn't seem to accept the 'old' erlang syntax. So in order to the plugin enabled, I assume I have to put this in the rabbitmq.conf : auth_backends.1 = rabbitmq_auth_backend_oauth2 auth_backends.2 = rabbitmq_auth_backend_internal

In the advanced.config file I have put the plugin config :

[ {rabbitmq_auth_backend_oauth2, [ {resource_server_id, <<"rabbitmq">>}, {key_config, [ {default_key, <<"legacy-token-key">>}, {signing_keys,

{<<"legacy-token-key">> => {pem, <<"-----BEGIN PUBLIC KEY-----

MY_KEY -----END PUBLIC KEY-----">>} } }] } ]} ].

At boot time, rabbit reports both config files : Starting broker...2019-12-23 19:13:53.071 [info] <0.284.0> node : rabbit@a572d2651761 home dir : /var/lib/rabbitmq config file(s) : /etc/rabbitmq/advanced.config : /etc/rabbitmq/rabbitmq.conf cookie hash : /0MsWyCszAs0rQsIG/NEpQ== log(s) : database dir : /var/lib/rabbitmq/mnesia/rabbit@a572d2651761

I also reports the plugin to be loaded : 2019-12-23 19:13:54.613 [info] <0.8.0> Server startup complete; 6 plugins started.

But no further logging of the oauth2 plugin, and login doesn't work : 2019-12-23 19:13:55.031 [info] <0.835.0> accepting Web MQTT connection <0.835.0> (172.21.0.2:34280 -> 172.21.0.4:15675) 2019-12-23 19:13:55.070 [error] <0.835.0> MQTT login failed: no username is provided 2019-12-23 19:13:55.071 [info] <0.835.0> MQTT protocol error unauthenticated for connection "172.21.0.2:34280 -> 172.21.0.4:15675"

What part am I doing wrong ?

peykens commented 4 years ago

When I check runtime config via rabbitmqctl environment I see :

{rabbit, [{auth_backends, [rabbitmq_auth_backend_oauth2,rabbitmq_auth_backend_internal]}, .......

and also : {rabbitmq_auth_backend_oauth2, [{key_config, [{default_key,<<"legacy-token-key">>}, {signing_keys,

{<<"legacy-token-key">> =>

                 {pem,
                     <<"-----BEGIN PUBLIC KEY-----my_key-----">>}}}]},
  {resource_server_id,<<"rabbitmq">>}]},
peykens commented 4 years ago

I'm getting one step further.

I now get a stack trace dump : 2019-12-23 20:39:51.723 [info] <0.3803.0> accepting Web MQTT connection <0.3803.0> (172.21.0.2:37696 -> 172.21.0.4:15675) 2019-12-23 20:39:51.897 [info] <0.3803.0> MQTT vhost picked using plugin configuration or default 2019-12-23 20:39:51.923 [info] <0.3803.0> closing Web MQTT connection <0.3803.0> (172.21.0.2:37696 -> 172.21.0.4:15675) 2019-12-23 20:39:51.926 [error] <0.3807.0> Generic server <0.3807.0> terminating Last message in was connect When Server state == {<0.3806.0>,{amqp_params_direct,<<"1576168428531">>,<<"d+oDSwuHKU2hRJJx1awrImQB618GliRIqCb2cKOkE+LL2TLZH/6BBenNLZCGDnFSoBx6dOwQAwtgcRHoChAhysWl84kn6dR18RVDXjNa/jvB4uM0JGogojx2c+mIuZh7yk5Y6vcJcLOEtLRW9l4ILHO4AZuoKDlnnKSXpHfRGP+pXs13fs6iMoQhY4mLaHoUx5ujLOROhreqqAoWM1uyRscx7Ddywoe4dFvT5MdnUiNGsu+MVnT8UY8eem7sapeyySFceTzCYUeQlooIq1L9jPXzQ4lkGNcg4UziIEx9SjNJVjcfUIqkga33nkV7Qc4UOanL29mnXb7AnlfH4cjm7qqHi/9KbluAfWlJnYxhk/YlWhE93vqtrD3KDNJ+bDGZh4gi0/HqWTg0w0hlferP6CP52LFLGYIZMNEXOuKACFUg2pvvqk1XBgTcEhe0sdw3j58TthqUOz46HCBcpVyfVYtqIfz5cE0K2fHzAF4ljiHM7k0an+x1GyO+OMfRxaLeFMVSYfQ6wyXlo0QDVX+3FXgA2w2mOkLU2bBtDzzofYDhTQ5yKT7x4Uw35kKeC+frXRDrB2B6GeEVu+l3Zg9Rr8kuIAnckTnl9O+WCucRyTTS8SjCjvqj7soGYHDMxr3pXn/4og0T5YZSomK75a1HEqvQm94sMTYvdu4u2lhsOcpGmjDSiXrBR4BDDeBXknyeBzDsM3//mUZv6bWuXklAK+qppjufXxyWxoSM7r37GY44GxQNykJGovJ49eJ4O4wEygH2j4yopsPrBNQs24pMHwwWKQGziEHyamzpubvj/c8hQuGvia7bp6AmmprLKQjQcfGlYhOaeSL7qvHAcBLwMAyovD21xl/IKxES+5ByjGFmdovZmhyQt2JuD/j16...">>,...}} Reason for termination == ** {function_clause,[{amqp_gen_connection,terminate,[{{case_clause,{badrpc,{'EXIT',{undef,[{rabbitmq_auth_backend_oauth2,user_login_authentication,[<<"1576168428531">>,[{password,<<"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InRhZGFhbV90ZW1wa2V5In0.eyJjdXN0b21lcklkIjoiMTU3NjE2ODQyODUzMSIsInN1YiI6IjE1NzYxNjg0Mjg1MzEiLCJ1c2VyX2lkIjoiMTU3NjE2ODQyODUzMSIsImNsaWVudF9pZCI6InJhYmJpdF9jbGllbnQiLCJjaWQiOiJyYWJiaXRfY2xpZW50Iiwicm9sZSI6ImN1c3RvbWVyIiwidXNlcm5hbWUiOiJ0YWRhYW0ucXVpY2tjaGVja180NTE5NkBnbWFpbC5jb20iLCJzY29wZSI6WyJyYWJiaXRtcS5yZWFkOiovKiIsInJhYmJpdG1xLndyaXRlOiovKiJdLCJhdWQiOlsicmFiYml0bXEiLCJyYWJiaXRfY2xpZW50Il0sImV4cCI6MTU3ODkzMzE1MCwiaWF0IjoxNTc3MTMzMTQ5fQ.V_q64BvfXdGFBSScHO_mm-xeS_5syjjHZ72s7KY2VQ3iSn0H9YcTmcP1sXKAMvISJTUzo0r9KndHmWW3hSI9y9jsBbBdG5694_UOPdCjf4sa-Af2wZh12HoMxfn486GRDV229RLcCjh5eFlhsJ9mlvPBJtMxbIcb92JWuU1Or9WKpb0R6p1NyrsN_ecrRVM8QYTS3lAQ9PzfkKa544_x448WFxdrJmNHr0coZ4A-1lcSjaZJ144f_gVnp6pceDeqFhvledgmurSG6WpJ7k...">>},...]],...},...]}}}},...},...],...},...]}

MarcialRosales commented 2 years ago

Hi @peykens , it is definitely not acceptable that i have not replied you until now. This issue has been completely off my radar. I believe you must be using a more recent version of RAbbitMQ and you do not have further issues.