Replies: 7 comments 11 replies
-
@hakan-77 "improve logging" is neither specific nor actionable. It cannot be an issue in its current form, our team has certain standards. RabbitMQ supports five IDPs and six configurations, some of which deviate from the standard specs, and the number of things that can go wrong is very broad. This complexity is inherent, We routinely hear request to reduce the amount RabbitMQ logs, including at debug level, Which is why we have extensive OAuth 2 documentation, examples, and a troubleshooting guide. |
Beta Was this translation helpful? Give feedback.
-
Please, don't do that. If you would like to see improved logging, submit pull requests. |
Beta Was this translation helpful? Give feedback.
-
@hakan-77 to give you an idea of how many different scenarios there are, take a look at the main OAuth 2 test suite. That's not everything, we have a comparable number in other suites/plugins plus an OAuth 2 client. In each scenario, a number of things can go wrong, from cryptographic operations-related to misconfigured IDP URIs and such. It's incredibly difficult to "improve logging" for all of them. For some specific well known cases, sure, but you haven't even mentioned what exactly were the issues in your case. Hence the suggestion to go straight to pull requests, for both the code and the documentation guides. Let's not pretend like it's a matter of adding a few logging lines in one module. |
Beta Was this translation helpful? Give feedback.
-
@michaelklishin I don't program in Erlang, but in other languages we usually have supporting JWT libraries that pinpoint the issue. A JWT token can be invalid for several different reasons. "Authentication using an OAuth 2/JWT token failed: provided token is invalid" does not give a clue why. Maybe you're parsing JWT yourself? Also, we don't know if the JWKS url is successfully parsed at first place, if public key is being used, and hence my feedback on logging the steps of the flow. As I mentioned before, we integrate with many platforms, from Grafana to harbor to gitea to ... you name it. This is the way pretty much all of these platforms OAuth work, helping users pinpoint issues. If you are truly interested in understanding how to improve the platform, I can help. If the only way to do this is to program in Erlang, then I'm not the right person. |
Beta Was this translation helpful? Give feedback.
-
OAuth provider: Custom Django OAuth, it is compatible with Keycloak. apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: my-rabbit
namespace: my-ns
spec:
replicas: 1
rabbitmq:
additionalPlugins:
- rabbitmq_auth_backend_oauth2
additionalConfig: |
log.default.level = debug
auth_backends.1 = rabbit_auth_backend_oauth2
auth_backends.2 = internal
management.oauth_enabled = true
management.oauth_client_id = 4F5Upg2dcFBlgan9yHldscNXgJBJQgy5gjNqcuXi
management.oauth_client_secret = ...
management.oauth_scopes = openid profile email username roles
management.oauth_provider_url = https://.../o
auth_oauth2.issuer = tried both https://.../o/ and also the JWT issuer: iss.mydomain.com (which fails faster)
auth_oauth2.preferred_username_claims.1 = username
auth_oauth2.preferred_username_claims.2 = email
auth_oauth2.jwks_url = https://.../o/.well-known/jwks.json
auth_oauth2.resource_server_id = rabbitmq
auth_oauth2.authorization_endpoint = https://.../o/authorize/
auth_oauth2.token_endpoint = https://.../o/token/
auth_oauth2.verify_aud = false
auth_oauth2.https.peer_verification = verify_none
auth_oauth2.algorithms.1 = RS256
auth_oauth2.https.fail_if_no_peer_cert = false JWT content: {"sub": "my_name@company.com",
"name": "my_name my_lastname", "given_name": "my_name",
"family_name": "my_lastname", "email": "my_name@company.com", "username": "my_name", "roles": "Admin",
"scope": ["rabbitmq.tag:administrator"] }
Server log:
Potential issues:
|
Beta Was this translation helpful? Give feedback.
-
Hi @hakan-77 , first of all thanks for reporting your issues with Oauth2 plugin. I would like that you bring up every issue you have had in the past troubleshooting an oauth2 issue so that we can do something about it. The troubleshooting guide that I have put together should serve 99% of all users troubleshooting an issue. I want users to go there first and from there advise them how to trouble shoot the issue they are having, for instance, advise them to the logs and search for some keywords or go to the console in the browser, etc. If the logs are not there to help troubleshoot a particular issue, we change the code. I think it can work well for both of us. Back to your issues. I dont know which version of RabbitMQ you are using, but if you look at this configuration file (https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/blob/main/conf/keycloak/rabbitmq.conf) that is used in the keycloak example you will see two key variables (by the way, most of the examples with other Idps also rely on the auto-discovery of endpoints..):
Please, let me know if you have more doubts/questions and more importantly, suggestions on how to improve the troubleshooting guide to help that potential user who may have the same issues you had. Thanks ! |
Beta Was this translation helpful? Give feedback.
-
Hi @MarcialRosales, Thank you for your response. I have went through the troubleshooting guide, but it didn't help. I will try again. I have to repeat my original ask, troubleshooting guides are great, but even better is the system logging what is wrong at first place. Until this happens, I'll do my best to improve the guide. Regarding issuer ("iss") requirement to be a url with https, I am copying directly from the url you shared https://openid.net/specs/openid-connect-core-1_0.html#IssuerIdentifier 16.15. Issuer Identifier OpenID Connect treats the path component of any Issuer URI as being part of the Issuer Identifier. For instance, the subject "1234" with an Issuer Identifier of "https://example.com" is not equivalent to the subject "1234" with an Issuer Identifier of "https://example.com/sales". It is RECOMMENDED that only a single Issuer per host be used. However, if a host supports multiple tenants, multiple Issuers for that host may be needed. This does not say "iss" needs to be a https url, but the examples they give use https urls. In my experience, some prefer "iss" to be a url, so end users can lookup, it guarantees uniqueness etc. and others prefer to keep it short since JWT tokens are notoriously long e.g. 500-600 chars in every http request header, in comparison to, say, github tokens 20-30 chars. And practically, I can confidently say other OAuth systems do not enforce such requirement. Since @michaelklishin mentioned you use https://github.com/potatosalad/erlang-jose library for jwt workloads, I got suspicious of their understanding of the JWT specification and wanted to open a ticket in that repo, but I see they do not enforce such a rule, and even their readme.md uses iss without https. Please check "usage" section of their read me file https://github.com/potatosalad/erlang-jose?tab=readme-ov-file#usage # JSON Web Token (JWT)
jwt = %{
"iss" => "joe",
"exp" => 1300819380,
"http://example.com/is_root" => true
} Lastly, I think it would be fantastic if you could check Grafana'a OAuth configuration https://grafana.com/docs/grafana/latest/setup-grafana/configure-security/configure-authentication/keycloak/ since it is one of the most popular services out there and their OAuth is extremely battle tested, and one of the best we experienced with, from config to logging. For OAuth configs, one provides url's (or one /well-defined url), a client id, a secret, scope, and you're good to go. Username/password login is left intact, so one has a backup plan to login in case OAuth doesn't work. Scopes are wrong? no problem, user is created with no permissions, and the "fallback admin" logs in w/ username/password, grants permissions manually.. and happy days. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
We have integrated OAuth to tens of 3rd party services and never have we struggled as much as we do with RabbitMQ. I will submit other issues, but most importantly we should improve logging. E.g. an error message like "Authentication using an OAuth 2/JWT token failed: provided token is invalid" does not help too much. What exactly is the issue? Is it wrong public key? "iss" not matching? expired token?
Describe the solution you'd like
Improved logging, at least for debug level. At least for errors, but ideally for all the auth flow events too.
Describe alternatives you've considered
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions