Design Decisions
Access token and ID token locations
All three location types work just as well for the filter to read from. For storing the newly acquired bearer token and ID token, however, it is important to keep in mind there will be redirects involved in the equation.
If you choose header
for storing an access token, the service that sits behind this proxy may or may not see this header. Let’s break this down to two scenarios:
- If a user is already authenticated and have an access code in the request header, the service will see this token because this filter will just let the request pass through.
- If a user is in the middle of authentication process and the filter just exchanged an access code with a bearer token, the filter will attach the newly acquired token to the response header and send back a
302 Found
response to the user. The user’s browser will then see that this response hasLocation
header set, and make a new request to the location specified. So the only audience of the token headers (if you so choose) is the user while the service behind this proxy will not see the token. In most cases, this is not what you want to configure to.
If you choose queryString
, the filter will append the token(s) to the URL that the user was originally trying to get to (before being redirected to authenticate). So the service behind this proxy will be able to read them.
cookie
is the most straight forward of the three. When the 302 response goes back to the user, it will set the cookie on their browser (which will be visible from the service when a new request gets created).
State Parameter
Although the main purpose of using the state parameter is to mitigate CSRF attacks, we are currently using this parameter to store the original URL that a user was trying reach before he/she was redirected to Identity Provider for authentication. This was taken from the existing implementation of the OpenID Connect authentication filter (gm.oauth
), and something to be aware of moving forward.
Refresh Tokens
The gm-oidc-authentication filter has the ability to refresh incoming tokens if they are expired. At this writing, only Keycloak is supported for token refresh.