dataset/seed/applicationservice/2022.03.08/mailman/manual/image/postinstall/risotto/views.py

26 lines
980 B
Python
Raw Normal View History

2022-03-08 19:42:28 +01:00
# -*- 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)