keycloak-nodejs-connect icon indicating copy to clipboard operation
keycloak-nodejs-connect copied to clipboard

add support for async guard function

Open jseparovic opened this issue 2 years ago • 2 comments

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

https://github.com/keycloak/keycloak-nodejs-connect/pull/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 avatar Mar 07 '22 06:03 jseparovic

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

jseparovic avatar Apr 27 '22 00:04 jseparovic

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

pjamroziak avatar Apr 29 '22 10:04 pjamroziak