Skip to content

Commit

Permalink
Allow a client to be registered on start up
Browse files Browse the repository at this point in the history
  • Loading branch information
markhobson committed Sep 17, 2024
1 parent 036ec1b commit 6b0d82e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ The server can be configured on start up using environment variables or at runti

### Environment variables

Use the following environment variables to create a user on start up:

| Name | Value |
|-----------------------|-----------------|
| FLASK_OIDC_USER_ID | OIDC user id |
| FLASK_OIDC_USER_EMAIL | OIDC user email |
Use the following environment variables to create a user and register a client on start up:

| Name | Value |
|--------------------------------|--------------------------|
| FLASK_OIDC_USER_ID | OIDC user id |
| FLASK_OIDC_USER_EMAIL | OIDC user email |
| FLASK_OIDC_CLIENT_ID | OIDC client id |
| FLASK_OIDC_CLIENT_REDIRECT_URI | OIDC client redirect URI |
| FLASK_OIDC_CLIENT_PUBLIC_KEY | OIDC client public key |
| FLASK_OIDC_CLIENT_SCOPE | OIDC client scope |

### Web API

Expand Down
10 changes: 10 additions & 0 deletions oidc_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ def create_app(test_config: dict[str, Any] | None = None) -> OidcServerApp:
if "OIDC_USER_ID" in app.config:
app.add_user(StubUser(id=app.config["OIDC_USER_ID"], email=app.config["OIDC_USER_EMAIL"]))

if "OIDC_CLIENT_ID" in app.config:
app.add_client(
StubClient(
client_id=app.config["OIDC_CLIENT_ID"],
redirect_uri=app.config["OIDC_CLIENT_REDIRECT_URI"],
public_key=app.config["OIDC_CLIENT_PUBLIC_KEY"],
scope=app.config["OIDC_CLIENT_SCOPE"],
)
)

key = RSAKey.generate_key(is_private=True)
authorization_server = app.create_authorization_server(key)
require_oauth = app.create_resource_protector()
Expand Down

0 comments on commit 6b0d82e

Please sign in to comment.