I need help with Authentication with APISIX, OIDC, and External SPA #12786
Replies: 1 comment 4 replies
-
|
Hi @BorisBeker! I'm Dosu and I’m helping the apisix team. To authenticate users with APISIX, OIDC, and an external SPA using Authorization Code Flow, you need to pay close attention to how the Redirect URI: Session Cookie: SPA Integration Patterns:
Troubleshooting Infinite Redirects:
Example Configuration: "redirect_uri": "https://your-domain.com/api/v1/redirect",
"session": {
"secret": "your-very-long-secret",
"cookie": {
"secure": true,
"samesite": "None",
"httponly": true
}
},
"bearer_only": false,
"unauth_action": "auth"Or, for SPA-managed authentication: "bearer_only": trueFor more details, see the official docs and related GitHub issues. Let me know if you want a diagram of the recommended flow or have questions about session sharing or advanced scenarios! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How do I authenticate a person attempting to access (let's say with a GET request) a protected route in APISIX using the OIDC plugin? I'm trying to use the Authorization Code Flow.
Since there's no session cookie, the user is redirected to Auth0's Universal Login, they authenticate, and then they are redirected back to the APISIX URL. Instead of this, it should redirect to the frontend and continue with the access to the protected resource. If I manually paste the frontend URL into the browser, and I have the session cookie, the GET request is attempted and works perfectly.
Trying another configuration, I end up with an infinite redirect to the frontend.
This is the configuration I provide through the APISIX dashboard:
{
"cache_prefix": "oidc_storage:",
"use_pkce": true,
"set_access_token_header": true,
"session_contents": {
"access_token": true
},
"access_token_in_authorization_header": false,
"set_id_token_header": true,
"discovery": "",
"set_userinfo_header": true,
"set_refresh_token_header": false,
"ssl_verify": false,
"redirect_after_logout_uri": "/callback",
"client_secret": "",
"renew_access_token_on_expiry": true,
"introspection_endpoint_auth_method": "client_secret_basic",
"token_endpoint_auth_method": "client_secret_basic",
"bearer_only": false,
"session": {
"secret": "",
"cookie": {
"secure": true,
"samesite": "None",
"httponly": true
}
},
"accept_none_alg": false,
"accept_unsupported_alg": true,
"access_token_expires_leeway": 0,
"force_reauthorize": false,
"use_nonce": false,
"access_token_expires_in": 3600,
"revoke_tokens_on_logout": false,
"timeout": 3,
"jwk_expires_in": 86400,
"logout_path": "/logout",
"jwt_verification_cache_ignore": false,
"iat_slack": 120,
"redirect_uri": "/api/v1/clients/callback",
"post_logout_redirect_uri": "/callback",
"introspection_interval": 0,
"client_jwt_assertion_expires_in": 60,
"unauth_action": "auth",
"scope": "openid profile email offline_access",
"client_id": "*********",
"realm": "apisix"
}
Beta Was this translation helpful? Give feedback.
All reactions