From f7e8fa460c83406596b28dccfc7dc2cd752d8a3e Mon Sep 17 00:00:00 2001 From: juanifioren Date: Mon, 13 Jul 2015 17:36:15 -0300 Subject: [PATCH] Create get_rsa_key function to obtain the key from filesystem. --- oidc_provider/lib/utils/common.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/oidc_provider/lib/utils/common.py b/oidc_provider/lib/utils/common.py index 7f0a626..9bf0357 100644 --- a/oidc_provider/lib/utils/common.py +++ b/oidc_provider/lib/utils/common.py @@ -1,16 +1,28 @@ +from django.conf import settings as django_settings from django.core.urlresolvers import reverse from oidc_provider import settings def get_issuer(): - """ - 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 + """ + 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 - return issuer + return issuer + + +def get_rsa_key(): + """ + Load the rsa key previously created with `creatersakey` command. + """ + file_path = django_settings.BASE_DIR + '/OIDC_RSA_KEY.pem' + with open(file_path, 'r') as f: + key = f.read() + + return key