Skip to content

Social logins: Set user to "Internal" only on given condition? #14040

Closed Answered by dewi-tik
fdcastel asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @fdcastel. An OAuth source property mapping should achieve what you're after. Something like this:

from authentik.core.models import UserTypes

email_name, email_domain = info["email"].rsplit("@", 1)
is_matching_domain = email_domain.endswith("contoso.com")

user_type = UserTypes.INTERNAL if is_matching_domain else UserTypes.EXTERNAL

return {
    "type": user_type,
}

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by fdcastel
Comment options

You must be logged in to vote
7 replies
@dewi-tik
Comment options

@fdcastel
Comment options

@dewi-tik
Comment options

@fdcastel
Comment options

@dewi-tik
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants