-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from makinacorpus/drf_spectacular_support
Add drf_spectacular schema generation
- Loading branch information
Showing
3 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.7 | ||
0.0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
try: | ||
from drf_spectacular.extensions import OpenApiAuthenticationExtension | ||
|
||
from django_pyoidc.utils import get_setting_for_sso_op | ||
|
||
class OIDCScheme(OpenApiAuthenticationExtension): | ||
target_class = "django_pyoidc.drf.authentication.OIDCBearerAuthentication" | ||
name = "openIdConnect" | ||
match_subclasses = True | ||
priority = -1 | ||
|
||
def get_security_definition(self, auto_schema): | ||
from django_pyoidc.drf.authentication import OIDCBearerAuthentication | ||
|
||
op = OIDCBearerAuthentication.extract_drf_opname() | ||
well_known_url = get_setting_for_sso_op(op, "OIDC_PROVIDER_DISCOVERY_URI") | ||
return {"type": "openIdConnect", "openIdConnectUrl": well_known_url} | ||
|
||
except ImportError: | ||
pass |