Debian Codegraph @

allauth/socialaccount/providers/lemonldap/provider.py

raw
1 from __future__ import annotations
2
3 from allauth.socialaccount.providers.base import ProviderAccount
4 from allauth.socialaccount.providers.lemonldap.views import LemonLDAPOAuth2Adapter
5 from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
6
7
8 class LemonLDAPAccount(ProviderAccount):
9 def get_avatar_url(self):
10 return self.account.extra_data.get("picture")
11
12
13 class LemonLDAPProvider(OAuth2Provider):
14 id = "lemonldap"
15 name = "LemonLDAP::NG"
16 account_class = LemonLDAPAccount
17 oauth2_adapter_class = LemonLDAPOAuth2Adapter
18
19 def get_default_scope(self):
20 return ["openid", "profile", "email"]
21
22 def extract_uid(self, data):
23 return str(data["id"])
24
25 def extract_common_fields(self, data):
26 return dict(
27 email=data.get("email"),
28 username=data.get("preferred_username"),
29 name=data.get("name"),
30 picture=data.get("picture"),
31 )
32
33
34 provider_classes = [LemonLDAPProvider]