Scenario:
app.com
has delegated authentication to openid-connect.provider.com
, meaning unauthenticated users are redirected to the external provider for signing in if they don't have a valid session. Once that has happened they get a session cookie on app.com
of some duration.
While the user-flow is fine, I was wondering what to do about API requests? The spec says that you if you return HTTP 401 UNAUTHORIZED
it needs to be accompanied by a WWW-Authenticate
header that presents an authentication scheme to the client.
So what should app.com
return in case of a 401?
I see bits and pieces indicating OAuth
, but I guess that pertains to the external provider of the login, not the application itself (app.com
)?
Example:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="example",
error="invalid_token",
error_description="The access token expired"
The above does not seem right, since the app.com
server doesn't use any access tokens in the oauth sense, just a plain session cookie for the local session.