Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for async guard function #355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jseparovic
Copy link

@jseparovic jseparovic commented Mar 7, 2022

Reviving the following old PR as I'm hitting the same issue:

#97

https://issues.redhat.com/browse/KEYCLOAK-5771?workflowName=GIT+Pull+Request+workflow+&stepId=4

I need to use an async GuardFn for my application.

I tested with a simple setTimeout method:

const keycloakGuardFn: KeycloakConnect.GuardFn = async (accessToken: Token, req: express.Request): Promise<boolean> => {
    const sleep = async (ms: number) => {
        return new Promise((resolve) => setTimeout(resolve, ms));
    }
    logger.trace("Sleeping for 2 seconds");
    await sleep(2000);
    logger.trace("Sleep finished");
    return true;
}

Looks fine in my testing.

Do I need to update the unit tests? I'm not too sure where/what to add here.

Cheers

@jseparovic
Copy link
Author

Any chance of merging this in? What needs to be done on my end? Cheers

@pjamroziak
Copy link

@jseparovic
Library will be deprecated :( I don't think, if they will merge your changes :/

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.

None yet

2 participants