Skip to content
Snippets Groups Projects
Commit 5c0639ac authored by Pomucz Tamás András's avatar Pomucz Tamás András
Browse files

Use schacc as email

parent 99956194
No related branches found
No related tags found
No related merge requests found
Pipeline #51663 passed
......@@ -4,10 +4,17 @@ from common.email import registration
class JSOIDCAuthBackend(OIDCAuthenticationBackend):
def get_email(self, claims):
sam_account_name = claims.get('directory.sch.bme.hu:sAMAccountName')
if sam_account_name:
return f"{sam_account_name}@sch.bme.hu"
return ""
def create_user(self, claims):
user = super(JSOIDCAuthBackend, self).create_user(claims)
user.first_name = claims.get('given_name', '')
user.last_name = claims.get('family_name', '')
user.email = self.get_email(claims)
user.save()
models.Profile.objects.create(user=user)
if user.email is not None:
......
......@@ -154,7 +154,7 @@ OIDC_OP_TOKEN_ENDPOINT = os.environ.get('OIDC_TOKEN_ENDPOINT')
OIDC_OP_USER_ENDPOINT = os.environ.get('OIDC_USERINFO_ENDPOINT')
OIDC_OP_JWKS_ENDPOINT = os.environ.get('OIDC_JWKS_ENDPOINT')
OIDC_RP_SIGN_ALGO = os.environ.get('OIDC_SIGN_ALGO', 'RS256')
OIDC_RP_SCOPES = os.environ.get('OIDC_RP_SCOPES', 'openid email profile offline_access')
OIDC_RP_SCOPES = os.environ.get('OIDC_RP_SCOPES', 'openid email profile offline_access directory.sch.bme.hu:sAMAccountName')
OIDC_VERIFY_KID = False
OIDC_EXEMPT_URLS = ["/healthz/", "/admin/", "/oidc/"]
LOGIN_REDIRECT_URL = "/"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment