Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to map user information during enrollment via oauth source #8342

Closed
tograss opened this issue Jan 29, 2024 · 6 comments · Fixed by #8392
Closed

How to map user information during enrollment via oauth source #8342

tograss opened this issue Jan 29, 2024 · 6 comments · Fixed by #8392
Labels
question Further information is requested

Comments

@tograss
Copy link
Contributor

tograss commented Jan 29, 2024

I'm trying to connect Authentik and Microsoft Entra ( former Azure AD) . I can setup the connection and login with my test user but how
do I map the properties from the entra user to the corresponding authentik user?
Any hints or a link to the relevant documentation would be really appreciated.

Maybe this can also be phrased as a more general question how to I map information from federated idp providers. For LDAP there are property mappings but the same does not exist for saml / oauth sources.

@tograss tograss added the question Further information is requested label Jan 29, 2024
@BeryJu
Copy link
Member

BeryJu commented Jan 29, 2024

Currently this has to be done in the enrollment/authentication flow through policies, before the user_write stage, you can access oauth_userinfo in the policy context to access the data from the userinfo endpoint.

(It's been on our roadmap for quite a long time to add property mappings for saml/oauth sources)

@tograss
Copy link
Contributor Author

tograss commented Jan 30, 2024

Thank you very much ! I got a working solution . Tomorrow or a least till end of this week I will add a pull request to improve the documentation. It might help others ( or me the next time ) .

@leisefuxX
Copy link

Thank you very much ! I got a working solution .

can u provide your mappings, for all us uninitiated users out there :D i have the same problem...

@tograss
Copy link
Contributor Author

tograss commented Feb 1, 2024

@leisefuxX Have a look at the pull request and let me know if its understandable . 😅

@leisefuxX
Copy link

hey @tograss

your solution works as intended and your documentation of the solution is also understandable and easy to follow.

It would be cool if a corresponding azure-enrollment was directly on board and you could simply click it together... maybe that would be something for 2023.10.8 (:

thanks for sharing and posting! you helped me a lot

@ll-innovationRD
Copy link

Currently this has to be done in the enrollment/authentication flow through policies, before the user_write stage, you can access oauth_userinfo in the policy context to access the data from the userinfo endpoint.

(It's been on our roadmap for quite a long time to add property mappings for saml/oauth sources)

hi,
I encountered the same issue with MS ENTRA/AzureAD. The request was successful, but the username field returned as AnonymousUser. It was clearly visible in the logs. The guide for Google describes the same problem and provides a solution at https://goauthentik.io/integrations/sources/google/.

The solution involves creating a policy expression and applying it to the flow that generates the user on the first access. I configured a policy like this:

username = request.context["oauth_userinfo"]["unique_name"]
request.user["username"] = username
return False

This way, the username field is populated correctly. You can also populate other fields such as email if they coincide:
request.user["email"] = username

I hope this can be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants