Skip to content

add support for async guard function#355

Open
asyncjason wants to merge 1 commit intokeycloak:mainfrom
asyncjason:async-guardfn
Open

add support for async guard function#355
asyncjason wants to merge 1 commit intokeycloak:mainfrom
asyncjason:async-guardfn

Conversation

@asyncjason
Copy link
Copy Markdown

@asyncjason asyncjason 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

@asyncjason
Copy link
Copy Markdown
Author

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

@pjamroziak
Copy link
Copy Markdown

@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.

2 participants