1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-15 22:37:40 +02:00
This commit is contained in:
quark 2025-06-14 18:01:42 +02:00
parent 89cc03141b
commit d71105976f

View File

@ -3,6 +3,7 @@
from oauth2_provider.oauth2_validators import OAuth2Validator
from oauth2_provider.scopes import BaseScopes
from member.models import Club
from note.models import Alias
from note_kfet.middlewares import get_current_request
from .backends import PermissionBackend
@ -35,7 +36,18 @@ class PermissionScopes(BaseScopes):
class PermissionOAuth2Validator(OAuth2Validator):
oidc_claim_scope = None # fix breaking change of django-oauth-toolkit 2.0.0
oidc_claim_scope = OAuth2Validator.oidc_claim_scope
oidc_claim_scope.update({"name": 'openid',
"normalized_name": 'openid',
"email": 'openid',
})
def get_additional_claims(self, request):
return {
"name": request.user.username,
"normalized_name": Alias.normalize(request.user.username),
"email": request.user.email,
}
def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):
"""