Commit 8623a2c3 authored by Jens Langhammer's avatar Jens Langhammer

oidc_provider: fix error trying to create RSA Key before migrations are run

parent 23d277ea
Pipeline #3891 passed with stage
in 2 minutes and 27 seconds
......@@ -2,6 +2,7 @@
from logging import getLogger
from django.apps import AppConfig
from django.db.utils import InternalError, OperationalError, ProgrammingError
from django.urls import include, path
LOGGER = getLogger(__name__)
......@@ -14,13 +15,16 @@ class PassbookOIDCProviderConfig(AppConfig):
verbose_name = 'passbook OIDC Provider'
def ready(self):
from Cryptodome.PublicKey import RSA
from oidc_provider.models import RSAKey
if not RSAKey.objects.exists():
key = RSA.generate(2048)
rsakey = RSAKey(key=key.exportKey('PEM').decode('utf8'))
rsakey.save()
LOGGER.info("Created key")
try:
from Cryptodome.PublicKey import RSA
from oidc_provider.models import RSAKey
if not RSAKey.objects.exists():
key = RSA.generate(2048)
rsakey = RSAKey(key=key.exportKey('PEM').decode('utf8'))
rsakey.save()
LOGGER.info("Created key")
except (OperationalError, ProgrammingError, InternalError):
pass
from passbook.root import urls
urls.urlpatterns.append(
path('application/oidc/', include('oidc_provider.urls', namespace='oidc_provider')),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment