Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Conversation

@valeriiduz
Copy link
Contributor

My team is using this lib in a commercial project to connect Keycloak from Fastapi and we observed this lib doesn't use timeout in connection to Keycloak, to avoid that I wrote this:

class CustomTimeout(TimeoutSauce):
    def __init__(self, *args, **kwargs):
        if kwargs['connect'] is None:
            kwargs['connect'] = 5
        if kwargs['read'] is None:
            kwargs['read'] = 5
        super().__init__(*args, **kwargs)


requests.adapters.TimeoutSauce = CustomTimeout
IDP = FastAPIKeycloak(
    server_url=KEYCLOAK_SERVER_URL,
    client_id=KEYCLOAK_CLIENT_ID,
    client_secret=KEYCLOAK_CLIENT_SECRET,
    admin_client_secret=KEYCLOAK_ADMIN_CLIENT_SECRET,
    realm=KEYCLOAK_REALM,
    callback_uri=KEYCLOAK_CALLBACK_URI,
)

And decided to add timeout to FastAPIKeycloak init. Code checked and all tests passed

Please review my PR and approve if it is okay for you to see timeout in this lib

@yannicschroeer
Copy link
Collaborator

Thank you for this contribution!

Copy link
Member

@JonasScholl JonasScholl left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@yannicschroeer yannicschroeer merged commit 85c452d into code-specialist:master May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants