Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Use ID token on refresh if access token is not a JWT #677

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yogu
Copy link

@Yogu Yogu commented Aug 7, 2020

Use ID token on refresh if access token is not a JWT

Summary

Currently, the refresh flow assumes that the access token is a JWT and if it isn't, the refresh fails. The initial token fetch routine already copes with this case by parsing the id token first, and only then tries to parse the access token. I copied the same logic into the token refresh routine.

Type

[x] Bug fix
[] Feature request
[] Enhancement
[] Docs

Why?

As far as I understand the OpenID Connect spec, you are not really supposed to parse the access token, and e.g. in the case of GitLab, it's not a JWT.

Requirements

Having an OIDC provider that sends access tokens that are not JWTs

How to try it?

Set up a GitLab application and use it, then see if the refresh flow works.

Additional informatoin

I don't really know either Go nor OpenID Connect, so please carefully review this and tell me if it makes sense.

Checklist:

  • My change requires a change to the documentation or CHANGELOG.
  • I have updated the documentation/CHANGELOG accordingly.


rawIDToken, ok := tkn.Extra("id_token").(string)
if !ok {
return jose.JWT{}, "", time.Time{}, time.Duration(0), errors.New("unable to obtain id token")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't need to fail here if we still can parse the access token

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant