-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging in with OIDC still redirects me to login page #534
Comments
Is this the full configuration ? |
i only put the parts that i thought were relevant, only other part of my config is my kafka connections. Ill take a look at #526 |
i updated my config to use the suggestion made in #526 : security:
default-group: no-roles
groups:
- name: admin
roles:
- topic/read
- topic/insert
- topic/delete
- topic/config/update
- node/read
- node/config/update
- topic/data/read
- topic/data/insert
- topic/data/delete
- group/read
- group/delete
- group/offsets/update
- registry/read
- registry/insert
- registry/update
- registry/delete
- registry/version/delete
- acls/read
- connect/read
- connect/insert
- connect/update
- connect/delete
- connect/state/update
- name: reader
roles:
- topic/read
- node/read
- topic/data/read
- group/read
- registry/read
- acls/read
- connect/read
- name: no-roles
roles: []
oidc:
enabled: true
providers:
oauth2:
label: "Login with MY_PROVIDER"
username-field: preferred_username
groups-field: roles
groups:
- name: ROLE_RETURNED_BY_PROVIDER
groups:
- reader However, after logging in i still get redirected to the login page (login with xxxx). When i go to /api/me i get something like: {"logged":true,"username":"schen2315","roles":["ROLE_1", "ROLE_2", "ROLE_3"]} Is there something wrong with my config? |
Not really sure to have understand ? Seems to be confusing here ! Just see also that you mix akhq & micronaut configuration. akhq:
security:
default-group: no-roles
groups: default & group, groups, .... are akhq configuration, not the micronaut one. |
my bad, im pasting what i think are relevant parts. My config does have security under akhq. micronaut:
security:
enabled: true
oauth2:
enabled: true
clients:
oauth2:
client-id: MY_CLIENT_ID
client-secret: MY_CLIENT_SECRET
openid:
issuer: MY_PROVIDER
akhq:
connections:
kafkasub:
properties:
bootstrap.servers: <MY_KAFKA_BROKER>
topic-data:
poll-timeout: 10000
security:
default-group: no-roles
groups:
- name: admin
roles:
- topic/read
- topic/insert
- topic/delete
- topic/config/update
- node/read
- node/config/update
- topic/data/read
- topic/data/insert
- topic/data/delete
- group/read
- group/delete
- group/offsets/update
- registry/read
- registry/insert
- registry/update
- registry/delete
- registry/version/delete
- acls/read
- connect/read
- connect/insert
- connect/update
- connect/delete
- connect/state/update
- name: reader
roles:
- topic/read
- node/read
- topic/data/read
- group/read
- registry/read
- acls/read
- connect/read
- name: no-roles
roles: []
oidc:
enabled: true
providers:
oauth2:
label: "Login with MY_PROVIDER"
username-field: sub
groups-field: roles
groups:
- name: ROLE_1
groups:
- reader Im using the role coming from my oidc provider. My understanding is that groups:
- name: ROLE_1
groups:
- reader means assign a user whose role |
to be honest, I never try this part, since I don't have any custom OIDC provider, i only try standard openid, @jniebuhr do it and maybe he have more information about this ? |
so we should set our oidc provider to return something like: {"logged":true,"username":"schen2315","groups":["ROLE_1", "ROLE_2", "ROLE_3"]} i believe for ldap, you are able to map groups returned by the ldap server to custom groups created in akhq. Is it not the same for oidc? |
As I understand here :
The default return was more like that :
Not really sure about that here, sorry ! |
@schen2315 You are correct, OIDC contains the same logic as LDAP. So the mapping is OIDC Groups -> AKHQ Groups -> AKHQ Roles. So it should work. There might be a conflict if the OIDC Claim is called |
I'm working on this exact same issue right now too. I found this comment: #485 (comment) saying that using the role name instead of a group should work. Can anyone confirm this for oidc? I'm unable to check this myself because of a bug in keycloak that prevents roles with a I will try to change the claim field to something else form the default My config looks pretty much the same as the one from @schen2315 except that i also have a jwt token in my config: micronaut:
security:
enabled: true
oauth2:
enabled: true
clients:
oidc:
client-id: "akhq-ui"
client-secret: "XXX-XXX-XXX"
openid:
issuer: "https://XXX-XXX-XXX/auth/realms/infrastructure/"
token:
jwt:
signatures:
secret:
generator:
secret: XXX-XXX-XXX Happy to also provide more of my config or some logs if necessary |
I tried to change the name of the field in my claim from
I'm also not 100% what the {
"sub": "XXXX",
"email_verified": true,
"akhqgroup": [
"topic-writer",
"admin"
],
"roles": [],
"iss": "akhq",
"typ": "ID",
"preferred_username": "XXXX",
"locale": "de",
"given_name": "XXXX",
"nonce": "XXXX",
"acr": "1",
"nbf": 1607520445,
"azp": "akhq-ui",
"auth_time": 1607520444,
"name": "XXXX",
"exp": 1607524045,
"session_state": "1838aebc-225f-4972-b45e-2bf3227b7e30",
"iat": 1607520445,
"family_name": "XXXX",
"email": "XXXX",
"oauth2Provider": "oidc"
} I tried the same with the role in the |
As I understand your payload must be : {
"sub": "XXXX",
"roles": [
"topic-writer",
"admin"
],
"iss": "akhq",
} do you try with that ? |
I tried with that payload, and had the same redirect problem.
Could you point in at the code where this mapping happens, I couldn't find it but I might be able to debug into this a little bit. |
The whole logic is here :
I think we could detail how it work and maybe adjust some naming that lead to confusion and make a big doc about that ! unfortunately, i don't have a custom oidc provider myself |
I finally tracked down the problem. This is also the reason why it works if your OIDC provider puts roles instead of groups into the claim. Question now is, what should be the intended behavior here? My personal preference would be to provide group memberships and not roles directly since it would mean creating all roles in your OIDC provider instead of just some groups that wrap all intended roles on akhq side (also if I read the doc correctly I think this is how it's supposed to work?) but not sure how other users use this. |
This is how I got it working hoeggi@341bc0d depending on what the actual intended behavior is I can open this as a PR if you want me to |
@hoeggi I would also prefer group from akhq, I think it was the actual behaviour.
Thanks for that |
I'll update the README and open a PR. Can you elaborate a bit more on the refactoring, not sure what exactly you mean here. |
for example: Oidc.Provider provider = oidc.getProvider(providerName);
if (attributes.containsKey(provider.getGroupsField())) {
attributes.put(provider.getGroupsField(), roles);
} getGroupsFields, roles seems to be a bug at first look 😄 |
It's actually the opposite :) without this, the attributes contain a field: roles=["admin"] what this does is, it overrides the value of the roles key so you get this instead (with all roles that match previously): roles=["topic/reader","topic/writer" ... ] In this example the |
So you want to provide roles from oidc instead of group ? |
Hello. We are experiencing the same problem with OIDC using Azure AD. It looks like we are logged in (we can see the usernames in the logs) but we are stuck at the login page and can't access anything in AKHQ. It's difficult to investigate since there is no DEBUG log in AKHQ so... we think it's a problem in the role and AKHQ group mapping code, but can't confirm. Is there a solution? |
Took me a while to get back to this,
So the problem is this:
what i did here:
was to override the wrongly mapped |
@hoeggi maybe a PR for that with some docs ? Thanks |
Hey guys,
I setup oidc and after authenticating am brought back to the login page (login with xxxx) and can't access the actual application. When i go to /api/me i see logged is set to true, my username is there and the roles that my company org returned. Do the roles returned by my provider have to match exactly to the roles used by akhq (e.g. topic/read, topic/insert, etc. ). I am on 0.16.0
Here's my config:
The text was updated successfully, but these errors were encountered: