-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic authn and authz implementation via keycloak and opa (#2)
- Loading branch information
1 parent
17d0d69
commit 34eba99
Showing
13 changed files
with
2,741 additions
and
101 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
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,22 @@ | ||
"""Authn and Authz module""" | ||
from fastapi_opa import OPAConfig | ||
from fastapi_opa.auth import OIDCAuthentication | ||
from fastapi_opa.auth import OIDCConfig | ||
|
||
from app.config.app import configuration as cfg | ||
|
||
|
||
# The hostname of your Open Policy Agent instance | ||
opa_host = cfg.OPA_URL | ||
# In this example we use OIDC authentication flow (using Keycloak) | ||
oidc_config = OIDCConfig( | ||
well_known_endpoint=cfg.OIDC_WELL_KNOWN_ENDPOINT, | ||
# well known endpoint | ||
app_uri=cfg.APP_URI, # host where this app is running | ||
# client id of your app configured in the identity provider | ||
client_id=cfg.OIDC_CLIENT_ID, | ||
# the client secret retrieved from your identity provider | ||
client_secret=cfg.OIDC_CLIENT_SECRET, | ||
) | ||
oidc_auth = OIDCAuthentication(oidc_config) | ||
opa_config = OPAConfig(authentication=oidc_auth, opa_host=opa_host) |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.