Skip to content

If using OIDC as security, API cannot be accesed using Authorization Bearer even after authenticating and getting and access token from OIDC #1055

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

Open
aalmenar opened this issue Apr 1, 2025 · 0 comments
Labels
area/security Related to security bug Something isn't working

Comments

@aalmenar
Copy link
Contributor

aalmenar commented Apr 1, 2025

Describe the bug

I tried accesing the API, which works perfectly when using basic authentication but when using oidc as security its not possible.

What do you see?

  • Requested a token on the token endpoint of the oidc to get an access token.
  • Use this token as "Authentication: Bearer $token"
  • Requesting /api/v1/config returns: {"oidc":true,"authenticated":false}
  • Requesting /api/v1/enpoints/statuses returns: token is missing or invalid

From the code i can see that this authentication will never happen since this is looked up in sessions.Get which is gocache storage, but was never set the with sessions.SetWithTTL because the token was requested to the OIDC.

So from what i can think (Maybe im wrong) but these tokens should be verified against the OIDC and not try to look them up in local gocache sessions storage since they will never be found there.

What do you expect to see?

To have access to the API

List the steps that must be taken to reproduce this issue

No response

Version

Latest from Git and latest docker image as of this writing

Additional information

I case of API access this can be considered M2M usage so:

  • Client Authentication – The machine authenticates using client credentials.
  • Token Request – The client requests an access token from the OIDC provider.
  • Token Response – The OIDC provider returns an access token (JWT).
  • API Request – The client includes the token in API requests.
  • API Authorization – The API verifies the token and processes the request.

Access token validation should be done using jwks using information in the jwks_uri found in the issuer-url + "/.well-known/openid-configuration", then that confirmation can be stored in gocache for fast access until expired.

@aalmenar aalmenar added the bug Something isn't working label Apr 1, 2025
@github-actions github-actions bot added the area/security Related to security label Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security Related to security bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant