Skip to content

Commit 9b7a678

Browse files
11 adapt to reference implementation (#12)
* Add FAPI URL and BAPI URL to config. * Adapt issuer validation * Rename short-term session to session-token * Bump release version to 2.0.0 * Rename get_and_validate_short_session_value to validate_token * Change validate_token error handling, add new exception type for session service * Adapt existing token validation tests to new error handling * Add new tests to session service for issuer validation and false private key * Add new test for issuer validation in session service * Update README.md * Remove session_token_cookie_name * Reorder required fields for configuration * Improved exception handling, renamed error codes * Change CORBADO_FRONTEND_API from variable to secret * reduce public fields of session service * update session token validation example * adjust workflow to use var instead of secret * return to public fields to make pydantic happy * Enable CI/CD on changes on merge request * Increase maximum line length on linting * Run CI/CD on Github Issue naming pattern * satisfy mypy * update generated client and openapi specs * enforce no trailing slashes in config urls * remove last_session_token_validation_result from session_service.py * satisfy flake8 * remove all usages of _set_validation_error * adjust test_set_cname_expect_issuer_changed to new url validation expectations * satisfy mypy * remove unnecessary file --------- Co-authored-by: Lukas Kratzel <lukas.kratzel2004@gmail.com>
1 parent 2e8c598 commit 9b7a678

67 files changed

Lines changed: 3642 additions & 323 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/python-package.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ name: Python package
44

55
on:
66
push:
7-
branches: [ "main","feature/**","development"]
7+
branches: [ "main","feature/**","development", "[0-9]+-*"]
88
tags:
99
- v[0-9]+.[0-9]+.[0-9]+*
1010
pull_request:
1111
branches: [ "main","development"]
12-
types: [opened, reopened]
12+
types: [opened, reopened, edited]
1313

1414
jobs:
1515
test-and-lint:
@@ -48,9 +48,11 @@ jobs:
4848
run: |
4949
tox run
5050
env:
51-
CORBADO_BACKEND_API: ${{ vars.CORBADO_BACKEND_API }}
52-
CORBADO_API_SECRET: ${{ secrets.CORBADO_API_SECRET }}
5351
CORBADO_PROJECT_ID: ${{ secrets.CORBADO_PROJECT_ID }}
52+
CORBADO_API_SECRET: ${{ secrets.CORBADO_API_SECRET }}
53+
CORBADO_FRONTEND_API: ${{ vars.CORBADO_FRONTEND_API }}
54+
CORBADO_BACKEND_API: ${{ vars.CORBADO_BACKEND_API }}
55+
5456

5557

5658
build:

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,23 @@ user_service: UserService = sdk.users
5757

5858
### Error handling
5959

60-
The Corbado Python SDK raises exceptions for all errors except those that occur in the session service during token validation (See example below on how to catch those errors). The following exceptions are thrown:
60+
The Corbado Python SDK raises exceptions for all errors. The following exceptions are thrown:
6161

6262
- `ValidationError` for failed validations (client side)
6363
- `ServerException` for server errors (server side)
64+
- `TokenValidationException` for errors in session service (client side)
6465
- `StandardException` for everything else (client side)
6566

66-
'SessionService' returns 'SessionValidationResult' as result of token validation. You can check whether any errors occurred and handle them if needed:
67+
`SessionService` returns a `UserEntity` as a result of token validation. If the token is invalid for any reason,
68+
a `TokenValidationException` is thrown. It provides detailed information on the error.
69+
If no error, is thrown, the `session_token` is valid and you can use the `UserEntity` object.
6770

6871
```Python
69-
result: SessionValidationResult = self.session_service.get_and_validate_short_session_value(short_session=token)
70-
if result.error is not None:
71-
print(result.error)
72-
raise result.error
72+
try:
73+
user: UserEntity = sdk.sessions.validate_token(session_token)
74+
except TokenValidationException:
75+
# handle error..
76+
pass
7377
```
7478

7579
If the Backend API returns a HTTP status code other than 200, the Corbado Python SDK throws a `ServerException`. The `ServerException`class provides convenient methods to access all important data:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.3
1+
2.0.0

0 commit comments

Comments
 (0)