Skip to content

SDK-2773-python-support-central-auth-tokens - #467

Merged
mehmet-yoti merged 2 commits into
developmentfrom
SDK-2773-python-support-central-auth-tokens
Nov 18, 2026
Merged

mehmet-yoti merged 2 commits into
developmentfrom
SDK-2773-python-support-central-auth-tokens

Conversation

@mehmet-yoti

Copy link
Copy Markdown
Contributor

Summary

Adds support for Yoti's new central auth token scheme alongside the existing signed-request scheme. The Relying Business can now choose, per client, whether the SDK authenticates outgoing requests with a PEM-signed digest or with a central auth token sent as an Authorization: Bearer <token> header.

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The updated request builder currently produces malformed URLs for non-signed auth strategies (trailing “?”), which is a correctness issue that should be fixed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds support for Yoti’s new central auth token authentication flow alongside the existing PEM-signed request mechanism, enabling per-client selection of how outgoing requests are authenticated.

Changes:

  • Introduces an AuthStrategy abstraction with implementations for signed-request, bearer token, and no-auth flows.
  • Updates Client, DocScanClient, and SignedRequest building to authenticate via an injected auth strategy (including bearer token support).
  • Adds a new AuthenticationTokenGenerator (PS384 JWT client assertion) plus accompanying tests.
File summaries
File Description
yoti_python_sdk/http.py Refactors SignedRequestBuilder to delegate auth headers/query params to an auth strategy.
yoti_python_sdk/auth_strategy.py Adds auth strategy abstractions and implementations (signed, bearer, none).
yoti_python_sdk/client.py Adds auth_token option and routes request signing/auth via the chosen strategy.
yoti_python_sdk/doc_scan/client.py Adds auth_token support and uses auth strategy instead of always requiring SDK ID + key.
yoti_python_sdk/crypto.py Adds PS384 signing helper used for JWT client assertions.
yoti_python_sdk/config.py Adds constants for Authorization/Bearer prefix usage.
yoti_python_sdk/auth/authentication_token_generator.py Implements central auth token generation via signed JWT client assertion.
yoti_python_sdk/auth/exception.py Adds a dedicated exception type for auth token generation failures (with OAuth error formatting).
yoti_python_sdk/auth/create_authentication_token_response.py Adds a response wrapper for auth token generation results.
yoti_python_sdk/auth/init.py Exposes central-auth public API exports.
yoti_python_sdk/tests/test_http.py Updates/extends request-building tests for bearer token and explicit auth strategies.
yoti_python_sdk/tests/test_crypto.py Adds tests verifying PS384 signatures are verifiable and detect tampering.
yoti_python_sdk/tests/test_client.py Adds tests covering Client(auth_token=...) validation and behavior.
yoti_python_sdk/tests/test_auth_strategy.py Adds unit tests for each auth strategy’s headers/query params behavior.
yoti_python_sdk/tests/doc_scan/test_doc_scan_client.py Adds Doc Scan client tests for token vs signed-request configuration rules.
yoti_python_sdk/tests/auth/test_exception.py Adds tests for AuthException formatting behavior across response types.
yoti_python_sdk/tests/auth/test_create_authentication_token_response.py Adds tests for token response parsing/defaults.
yoti_python_sdk/tests/auth/test_authentication_token_generator.py Adds tests for generator builder validation, request payload, and error handling.
yoti_python_sdk/tests/auth/init.py Adds test package initializer for auth test suite.
Review details

Suppressed comments (1)

yoti_python_sdk/auth_strategy.py:35

  • Abstract methods should raise NotImplementedError rather than returning the NotImplemented singleton; returning NotImplemented can lead to confusing downstream failures if the method is ever invoked directly.
    @abstractmethod
    def create_query_params(self):
        """
        Returns a dict of query params required to authenticate the request
        """
        return NotImplemented
  • Files reviewed: 18/19 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

"scope": " ".join(scopes),
}

response = requests.post(self.__auth_api_url, data=form_data)
Comment thread yoti_python_sdk/http.py Resolved
Comment thread yoti_python_sdk/auth_strategy.py Resolved
Comment thread yoti_python_sdk/auth_strategy.py Resolved
def __init__(self, sdk_id, key, api_url=None):
self.__sdk_id = sdk_id
self.__key = key
def __init__(self, sdk_id=None, key=None, api_url=None, auth_token=None):
payload = {
"iss": issuer,
"sub": issuer,
"aud": self.__auth_api_url,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mehmet-yoti still needs addressing

- Add jti (UUID v4) claim to the client assertion JWT, with an optional
  with_jwt_id_supplier() builder override (parity with PHP/Java)
- Add a configurable timeout to the auth token request (default 30s)
- Don't append a trailing '?' to URLs when there are no query params
- Abstract AuthStrategy methods raise NotImplementedError
- Fix 'compatibility' typo and update DocScanClient docstring
@sonarqubecloud

Copy link
Copy Markdown

@nikhilPank nikhilPank left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - working now

@mehmet-yoti
mehmet-yoti merged commit 08fac14 into development Nov 18, 2026
13 checks passed
@mehmet-yoti mehmet-yoti mentioned this pull request Nov 18, 2026
mehmet-yoti added a commit that referenced this pull request Nov 18, 2026
* SDK-2773-python-support-central-auth-tokens

* fix(SDK-2773): add jti claim to auth JWT and address review comments

- Add jti (UUID v4) claim to the client assertion JWT, with an optional
  with_jwt_id_supplier() builder override (parity with PHP/Java)
- Add a configurable timeout to the auth token request (default 30s)
- Don't append a trailing '?' to URLs when there are no query params
- Abstract AuthStrategy methods raise NotImplementedError
- Fix 'compatibility' typo and update DocScanClient docstring
mehmet-yoti added a commit that referenced this pull request Nov 25, 2026
* SDK-2488: Python - Support dark mode in IDV SDK - python (#466)

* Add dark_mode and primary_colour_dark_mode to SdkConfig (SDK-2488)

Extends SdkConfig and SdkConfigBuilder with two new optional fields:
- dark_mode (with_dark_mode, with_dark_mode_on/off/auto convenience methods)
- primary_colour_dark_mode (with_primary_colour_dark_mode)

Both fields are omitted from the JSON payload when not set (None).
* feat(SDK-2488): Python - Support dark mode in IDV SDK [python]
* SDK-2751: Add  to Python SDK IDV Create Session (#470)
* SDK-2530-python-create-helper-methods-for-the-idv-sdk (#468)
* SDK-2773-python-support-central-auth-tokens (#467)
* SDK-2773-python-support-central-auth-tokens
* fix(SDK-2773): add jti claim to auth JWT and address review comments
- Add jti (UUID v4) claim to the client assertion JWT, with an optional
  with_jwt_id_supplier() builder override (parity with PHP/Java)
- Add a configurable timeout to the auth token request (default 30s)
- Don't append a trailing '?' to URLs when there are no query params
- Abstract AuthStrategy methods raise NotImplementedError
- Fix 'compatibility' typo and update DocScanClient docstring

* Merge pull request #471 from getyoti/websdk-auto/SDK-2869-python-support-fetching-session-pdf-in-idv
SDK-2869: Python - Support fetching session PDF in IDV - python
* Sdk 2802 python remove the api for aml check in connect (#469)
* SDK-2802-python-remove-the-api-for-aml-check-in-connect
* ci: pin runners to ubuntu-24.04 so Python 3.9 is still available
ubuntu-latest moved to Ubuntu 26.04, which has no Python 3.9 build in
actions/python-versions. The SDK still supports 3.9 (python_requires>=3.9).
* feat(SDK-2827): Python - Support company_profile for IDV [python] (#472)
* Bump version to 2.15.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants