2015-07-13 20:36:15 +00:00
|
|
|
from django.conf import settings as django_settings
|
2015-03-04 19:24:41 +00:00
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
|
|
|
|
from oidc_provider import settings
|
|
|
|
|
|
|
|
|
|
|
|
def get_issuer():
|
2015-07-13 20:36:15 +00:00
|
|
|
"""
|
|
|
|
Construct the issuer full url. Basically is the site url with some path
|
|
|
|
appended.
|
|
|
|
"""
|
|
|
|
site_url = settings.get('SITE_URL')
|
|
|
|
path = reverse('oidc_provider:provider_info') \
|
|
|
|
.split('/.well-known/openid-configuration/')[0]
|
|
|
|
issuer = site_url + path
|
2015-03-04 19:24:41 +00:00
|
|
|
|
2015-07-13 20:36:15 +00:00
|
|
|
return issuer
|
|
|
|
|
|
|
|
|
|
|
|
def get_rsa_key():
|
|
|
|
"""
|
|
|
|
Load the rsa key previously created with `creatersakey` command.
|
|
|
|
"""
|
2015-07-14 16:01:29 +00:00
|
|
|
file_path = settings.get('OIDC_RSA_KEY_FOLDER') + '/OIDC_RSA_KEY.pem'
|
2015-07-14 18:01:01 +00:00
|
|
|
try:
|
|
|
|
with open(file_path, 'r') as f:
|
|
|
|
key = f.read()
|
|
|
|
except IOError:
|
|
|
|
raise IOError('We could not find your key file on: ' + file_path)
|
2015-07-13 20:36:15 +00:00
|
|
|
|
|
|
|
return key
|