Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

BAD RPC Response code #37

Closed
peykens opened this issue Dec 28, 2019 · 4 comments
Closed

BAD RPC Response code #37

peykens opened this issue Dec 28, 2019 · 4 comments

Comments

@peykens
Copy link

peykens commented Dec 28, 2019

I'm trying to get this oauth2 backend working since it's the perfect solution for our system.

But I'm always running into a badrcp error when a user connects :
{function_clause,[{amqp_gen_connection,terminate,[{{case_clause,{badrpc,{'EXIT',{undef,[{rabbitmq_auth_backend_oauth2,user_login_authentication,

Stack trace :
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...">>},...]],...},...]}}}},...},...],...},...]}

Maybe I'm missing some part in my token, but I can't find a complete example.
Does anyone has a valid token which works ?

@peykens
Copy link
Author

peykens commented Dec 28, 2019

My token payload contains :

"customerId": "1576168428531",
"sub": "1576168428531",
"user_id": "1576168428531",
"client_id": "rabbit_client",
"cid": "rabbit_client",
"role": "customer",
"scope": [
"rabbitmq.read:/",
"rabbitmq.write:/"
],
"aud": [
"rabbitmq",
"rabbit_client"
]

@michaelklishin
Copy link
Member

The node in question does not have the rabbitmq_auth_backend_oauth2:user_login_authentication/3 function on code path. Either the plugin is not installed there, or it was not enabled.

@michaelklishin michaelklishin transferred this issue from rabbitmq/rabbitmq-auth-backend-oauth2 Dec 29, 2019
@peykens
Copy link
Author

peykens commented Dec 29, 2019

Hi @michaelklishin ,

The plugin was enabled however and is running.

rabbitmq-plugins list
...
[E*] rabbitmq_auth_backend_oauth2 3.8.2
...

rabbitmqctl environment
{rabbitmq_auth_backend_oauth2,
[{key_config,
[{default_key,<<"tadaam_tempkey">>},
{signing_keys,
#{<<"tadaam_tempkey">> =>
{pem,
<<"-----BEGIN PUBLIC KEY----------END PUBLIC KEY-----">>}}}]},
{resource_server_id,<<"rabbitmq">>}]},

and in rabbitmq.conf :
auth_backends.1 = rabbitmq_auth_backend_oauth2

I'm running on a single rabbitmq node

@peykens
Copy link
Author

peykens commented Dec 29, 2019

OK found it.

The config should not be :
auth_backends.1 = rabbitmq_auth_backend_oauth2

but should be:
auth_backends.1 = rabbit_auth_backend_oauth2

Now it reaches the plugin, and I get refused back. At least I reach the pluging now.

Thx @michaelklishin for the tip

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants