| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from allauth.socialaccount.providers.base import ProviderAccount |
| 4 |
from allauth.socialaccount.providers.netiq.views import NetIQOAuth2Adapter |
| 5 |
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider |
| 6 |
|
| 7 |
|
| 8 |
class NetIQAccount(ProviderAccount): |
| 9 |
pass |
| 10 |
|
| 11 |
|
| 12 |
class NetIQProvider(OAuth2Provider): |
| 13 |
id = "netiq" |
| 14 |
name = "NetIQ" |
| 15 |
account_class = NetIQAccount |
| 16 |
oauth2_adapter_class = NetIQOAuth2Adapter |
| 17 |
|
| 18 |
def get_default_scope(self): |
| 19 |
return ["openid", "profile", "email"] |
| 20 |
|
| 21 |
def extract_uid(self, data): |
| 22 |
uid_field = self.app.settings.get("uid_field", "sub") |
| 23 |
return str(data[uid_field]) |
| 24 |
|
| 25 |
def extract_extra_data(self, data): |
| 26 |
return data |
| 27 |
|
| 28 |
def extract_common_fields(self, data): |
| 29 |
return dict( |
| 30 |
email=data["email"], |
| 31 |
last_name=data["family_name"], |
| 32 |
first_name=data["given_name"], |
| 33 |
) |
| 34 |
|
| 35 |
|
| 36 |
provider_classes = [NetIQProvider] |