juanifioren / django-oidc-provider

OpenID Connect and OAuth2 provider implementation for Djangonauts.
http://django-oidc-provider.readthedocs.org
MIT License
416 stars 239 forks source link

Programatically set RSA Keys for testing purposes #384

Closed tandrade96 closed 3 years ago

tandrade96 commented 3 years ago

TLDR: Is there a way to programmatically create an RSA Key? I need it to test my oidc middleware

I am testing an app that uses django-oidc-provider, and as far as I get to understand, many operations require that an RSA key is registered (for example if I request for authorize with a token flow, it answers with the You must add at least one RSA Key exception).

My problem is I don't know how to set that RSA Key creation inside my tests programmatically, I have only found about python manage.py create rsa key but it's not what I am looking for because it is not automatic

Thank you!

JackAtOmenApps commented 3 years ago

Other than imports, the rsa key generation is only 3 lines.

Check out how it's accomplished in the management command here: https://github.com/juanifioren/django-oidc-provider/blob/master/oidc_provider/management/commands/creatersakey.py

tandrade96 commented 3 years ago

Thank you so much!