Closed ricardogsilva closed 6 years ago
Seems like I made some git mistake while trying to apply this PR into my own fork... I'll try to undo things in order to have just the relevant changes be a part of this PR.
I'm closing this PR and submitting a new one with only the relevant modifications...
This PR modifies the authentication backend in order to only allow logging in if the access token's
aud
claim contains one of the trusted audiences.Trusted audiences can be defined in the already existing setting
settings.OIDC_AUTH["OIDC_AUDIENCES]
Other implementation notes
The
client_id
of the current django project is automatizally added to theOIDC_AUDIENCES
list if not already thereAccording to the openid-connect spec, a token's
aud
claim can be either a list or a string. This PR handles both casesThe check for a valid access token is done inside the
get_user_by_id
function in order to make it available also for users that are logging in via django-rest-framework, with the drf-oidc-auth package