dataset/seed/mailman/manual/image/postinstall/risotto/views.py
2022-07-01 22:10:33 +02:00

25 lines
980 B
Python

# -*- coding: utf-8 -*-
import requests
from allauth.socialaccount.providers.lemonldap.views import LemonLDAPOAuth2Adapter
from allauth.socialaccount.providers.risotto.provider import RisottoProvider
from allauth.socialaccount import app_settings
from allauth.socialaccount.providers.oauth2.views import (
OAuth2CallbackView,
OAuth2LoginView,
)
class RisottoOAuth2Adapter(LemonLDAPOAuth2Adapter):
provider_id = RisottoProvider.id
settings = app_settings.PROVIDERS.get(provider_id, {})
provider_base_url = settings.get("LEMONLDAP_URL")
provider_base_local_url = settings.get("LEMONLDAP_LOCAL_URL")
access_token_url = "{0}/oauth2/token".format(provider_base_local_url)
authorize_url = "{0}/oauth2/authorize".format(provider_base_url)
profile_url = "{0}/oauth2/userinfo".format(provider_base_local_url)
oauth2_login = OAuth2LoginView.adapter_view(RisottoOAuth2Adapter)
oauth2_callback = OAuth2CallbackView.adapter_view(RisottoOAuth2Adapter)