oidc_provider: fix error trying to create RSA Key before migrations are run
This commit is contained in:
parent
23d277eaf1
commit
8623a2c3fc
|
@ -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,6 +15,7 @@ class PassbookOIDCProviderConfig(AppConfig):
|
|||
verbose_name = 'passbook OIDC Provider'
|
||||
|
||||
def ready(self):
|
||||
try:
|
||||
from Cryptodome.PublicKey import RSA
|
||||
from oidc_provider.models import RSAKey
|
||||
if not RSAKey.objects.exists():
|
||||
|
@ -21,6 +23,8 @@ class PassbookOIDCProviderConfig(AppConfig):
|
|||
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')),
|
||||
|
|
Reference in New Issue