Skip to content

Commit

Permalink
update client, fix issue with env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
kipparker committed Apr 17, 2024
1 parent 75418be commit b09a3cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ python -W ignore client.py id-token --token <token>

with token being the `id_token` value obtained from authorisation code flow

### Retrieve data from protected endpoint

```bash
python -W ignore client.py resource --token <token>
```

## Ory Hydra

Please contact IB1 for the Client ID and secret if you would like to test against our demo Ory account. Alternatively you can set up a free developer account and create an Oauth2 client with your own details. The client should have:
Expand Down
2 changes: 1 addition & 1 deletion authentication/copilot/backend/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ network:
variables: # Pass environment variables as key value pairs.
CLIENT_ID: f67916ce-de33-4e2f-a8e3-cbd5f6459c30
REDIS_HOST: redis.${COPILOT_ENVIRONMENT_NAME}.${COPILOT_APPLICATION_NAME}.local
OAUTH_URL: https://vigorous-heyrovsky-1trvv0ikx9.projects.oryapis.com/
OAUTH_URL: https://vigorous-heyrovsky-1trvv0ikx9.projects.oryapis.com



Expand Down
27 changes: 12 additions & 15 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ def id_token(token):
print(client_side_decoding(token))


@click.option("--token", help="Authorisation token")
@cli.command()
def resource(token):
result = requests.get(
f"{RESOURCE_API}/api/v1/consumption",
verify=False,
headers={"Authorization": f"Bearer {token}"},
cert=(CLIENT_CERTIFICATE, CLIENT_PRIVATE_KEY),
)
return result.json()


@cli.command()
def auth():
code_verifier, par_response = pushed_authorization_request()
Expand All @@ -187,18 +199,3 @@ def auth():

if __name__ == "__main__":
cli()
# Initiate flow with PAR

# Generate PKCE code verifier and challenge

# The following two tests will use the values returned after login and consent has been given
# print(
# introspect_token(
# "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOltdLCJj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