Repository navigation
Azure AD support #290
Description
i'm working on an integration with azure AD. after a successful login, vouch unpacks the body of the OIDC /userinfo response into a structs.User object, which takes values from fields username, email etc.
| if err = json.Unmarshal(data, user); err != nil { |
when constructing the jwt to store, the claims are constructed using this structs.User.Username.
vouch-proxy/pkg/jwtmanager/jwtmanager.go
Line 81 in 1f68466
| u.Username, |
later when checking the token in /validate, vouch checks if the username is populated and returns 401 if is not.
vouch-proxy/handlers/validate.go
Line 48 in 4b6d226
| if claims.Username == "" { |
this logic makes the assumption that username is included in the /userinfo response, which in my case it is not. 😞
is there a way to take information like this from the ID token instead of the /userinfo response? in azure AD, i can't configure which fields are included in the /userinfo response (e.g. to add the user's email address), but i can configure which fields are included in the tokens.
vouch config for posterity:
VOUCH_JWT_MAXAGE=20
VOUCH_ALLOWALLUSERS=true
VOUCH_LOGLEVEL=debug
VOUCH_COOKIE_SECURE=false
VOUCH_COOKIE_DOMAIN=localhost
OAUTH_PROVIDER=oidc
OAUTH_CLIENT_ID=...
OAUTH_CLIENT_SECRET=...
OAUTH_BASEURL=https://login.microsoftonline.com/...
OAUTH_AUTH_URL=https://login.microsoftonline.com/.../oauth2/v2.0/authorize
OAUTH_TOKEN_URL=https://login.microsoftonline.com/.../oauth2/v2.0/token
OAUTH_USER_INFO_URL=https://graph.microsoft.com/oidc/userinfo
OAUTH_SCOPES=openid,profile,email
OAUTH_CALLBACK_URLS=http://localhost:9090/auth
Activity
[-]openid provider makes assumptions about claims included in `userinfo` response[/-][+]oidc provider makes assumptions about claims included in `userinfo` response[/+]bnfinet commentedon Jul 8, 2020
@tomsmyers have you tried using the
adfsprovider? IIRC it uses the same interfaces as Azure AD. A quick view of theadfs.gocode shows it falling back to using theUPNif an email isn't present.https://github.com/vouch/vouch-proxy/blob/master/config/config.yml_example_adfs
[-]oidc provider makes assumptions about claims included in `userinfo` response[/-][+]oidc provider `userinfo` response expects `u.Username`, breaks Azure AD if it isn't populated[/+]tomsmyers commentedon Jul 9, 2020
unfortunately using the
adfsprovider does not work with azure AD; you get the errorThe 'resource' request parameter is not supported.when redirecting to the login page.bnfinet commentedon Jul 9, 2020
@simongottschlag do you have any insight into Azure AD setups? ^^
@tomsmyers if you'd care to add a new provider at
providers/azure/azure.goI'd be happy to accept a PR. I'm not a user of Azure so I'm not in a position to test/support Azure AD at this time.[-]oidc provider `userinfo` response expects `u.Username`, breaks Azure AD if it isn't populated[/-][+]Azure AD support[/+]simongottschlag commentedon Jul 9, 2020
@bnfinet Azure AD has their own quirks compared to ADFS. The resource query parameter is required with ADFS to populate the claims correctly while causing issues with Azure AD.
There are also differences with using Azure AD with a single tenant and using the “multi-tenant” endpoints and may require additional configuration to get both working.
tomsmyers commentedon Jul 10, 2020
thanks for the comments, i opened a PR to add support for my azure ad config by simply mapping
upnclaim to username and email (based on the docs,upnis an email address), unless the fields already exist in the token.#292
#290 provide example config
bnfinet commentedon Jul 10, 2020
@tomsmyers thanks much for the addition to VP!
sintaxx commentedon Mar 8, 2021
Has anyone any documentation on how to setup Vouch with Azure AD sitting behind an nginx reverse proxy ? This would be amazing.
jastlw commentedon Dec 23, 2022
@simongottschlag Can I also configure azure_token through environmental variables for OAuth config?
I want to use it with docker compose:
With reference to #320
I think I am not sure yet, if I really need to set the "OAUTH_AZURE_TOKEN".
Thank you in advance.
bnfinet commentedon Dec 23, 2022
@jastlw it should but that may have been overlooked when we implemented config via environmental variables.
Could you please test that, and open a new issue if it does not work?
jastlw commentedon Jul 26, 2023
@bnfinet I forgot to give the feedback: it is working. :)
@sintaxx I used nginx-proxy with the following configs as Per-VIRTUAL_HOST and Per-VIRTUAL_HOST location configuration
app.domain.de
app.domain.de_location
Thanks a lot!