2019-03-18 19:35:11 +00:00
|
|
|
"""passbook oauth provider OpenID Views"""
|
|
|
|
|
|
|
|
from django.http import HttpRequest, JsonResponse
|
|
|
|
from django.shortcuts import reverse
|
|
|
|
from django.views.generic import View
|
|
|
|
|
|
|
|
|
|
|
|
class OpenIDConfigurationView(View):
|
|
|
|
"""Return OpenID Configuration"""
|
|
|
|
|
2019-06-25 15:57:25 +00:00
|
|
|
def get_issuer_url(self, request):
|
|
|
|
"""Get correct issuer URL"""
|
|
|
|
full_url = request.build_absolute_uri(reverse('passbook_oauth_provider:openid-discovery'))
|
|
|
|
return full_url.replace(".well-known/openid-configuration", "")
|
|
|
|
|
2019-03-18 19:35:11 +00:00
|
|
|
def get(self, request: HttpRequest):
|
|
|
|
"""Get Response conform to https://openid.net/specs/openid-connect-discovery-1_0.html"""
|
|
|
|
return JsonResponse({
|
2019-06-25 15:59:51 +00:00
|
|
|
'issuer': self.get_issuer_url(request),
|
2019-03-18 19:35:11 +00:00
|
|
|
'authorization_endpoint': request.build_absolute_uri(
|
|
|
|
reverse('passbook_oauth_provider:oauth2-authorize')),
|
|
|
|
'token_endpoint': request.build_absolute_uri(reverse('passbook_oauth_provider:token')),
|
|
|
|
"jwks_uri": request.build_absolute_uri(reverse('passbook_oauth_provider:openid-jwks')),
|
|
|
|
"scopes_supported": [
|
2019-06-25 15:57:25 +00:00
|
|
|
"openid",
|
2019-03-18 19:35:11 +00:00
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
class JSONWebKeyView(View):
|
|
|
|
"""JSON Web Key View"""
|
|
|
|
|
|
|
|
def get(self, request: HttpRequest):
|
|
|
|
"""JSON Webkeys are not implemented yet, hence return an empty object"""
|
|
|
|
return JsonResponse({})
|