Describe the issue:
I’m configuring OpenID authentication on opensearch/opensearch dashboards. I’m attaching the configurations. The SSO backend is authentik. I’m getting the error {“statusCode”:401,“error”:“Unauthorized”,“message”:“Unauthorized”}
Despite the debug logs, I can’t figure out the problem. Authentication appears to be occurring correctly. I’m not seeing any errors related to the endpoint being unreachable.
I tried returning the role scope as “all_access” or “kibana_server” as per the role_mapping file, but it didn’t work.The error in the opensearch log is
\[2025-10-06T17:33:32,109\]\[DEBUG\]\[o.o.s.a.BackendRegistry \] \[node.domain.com\] Check authdomain for rest internal/0 or 2 in total
\[2025-10-06T17:33:32,109\]\[DEBUG\]\[o.o.s.a.BackendRegistry \] \[node.domain.com\] Check authdomain for rest noop/1 or 2 in total
\[2025-10-06T17:33:32,109\]\[DEBUG\]\[o.o.s.a.BackendRegistry \] \[node.domain.com\] User still not authenticated after checking 2 auth domains
\[2025-10-06T17:33:32,110\]\[WARN \]\[o.o.s.a.BackendRegistry \] \[node.domain.com\] Authentication finally failed for null from 127.0.0.1:36870
@antekronos I’ve got Authentik working with OpenSearch but I used ‘groups’ instead of ‘roles’ as roles_key in config.yml.
Also, if you’re using a proxy, be sure that all headers from opensearch.requestHeadersWhitelist are passed.
Last one, please replace opensearch.requestHeadersWhitelist with opensearch.requestHeadersAllowlist as opensearch.requestHeadersWhitelist is deprecated.
I’ve already tried using groups instead of roles, but the error doesn’t change.
I’m attaching the current contents of roles_mapping and roles. I want to match the groups “admins” with the roles all_access. Is there something I’m doing wrong?
I modified opensearch.requestHeadersAllowlist as indicated.
@antekronos, Your backend_roles in mappings refer only to admin. Does your Authentik’s user has an admin group/role assigned?
If not, then Authentik’s group should be included in the backend_roles.
If this is a dev/test environment, you can set users to * in the all_access and then check through Dev tools what groups were passed from Authentik
If its an authentication issue, then roles mappings do not matter so focus on authentication. It sounds like the tokens from the IdP are getting dropped. Is there a proxy in the mix?
I don’t think it matters, but when you enable multi auth you should be defining the sign in options as a list.
I found the solution!
Opensearch doesn’t handle encryption on the JWT token, the token generated by Authentik was in JWE format. I disabled encryption, and Opensearch was able to read the scopes.
I’ll point you to my documentation for anyone who might need it in the future.
In the multi-auth configuration, I kept both OpenID and BasicAuth as a fallback in case of problems with OpenID. Now I’m using only OpenID without any problems.
Please note that JWT tokens are only signed but do not use encryption.
I’m using Caddy as a reverse proxy for dashboards without any problems.