Skip to content

Bug: ShouldAddToken is adding bearer token to every url #627

@gerwinbouwhuis

Description

@gerwinbouwhuis

I use the shouldAddToken token with customBearerTokenInterceptor, but it seems like the bearer token is added to every url, if return false it still added the bearer token,
If using the urlPattern with includeBearerTokenInterceptor it, then it works like expected

const customCondition: CustomBearerTokenCondition = {
    shouldAddToken: async (req: any, next: HttpHandlerFn, keycloak: Keycloak) => {
        // Add token only for requests to the / api endpoint
        return req.url.startsWith('/api') && keycloak.authenticated;
    }
};

I think something goes wrong here, shouldAddToken is false but it 's find a matching condition
const matchingCondition = conditions.find(async condition => await condition.shouldAddToken(req, next, keycloak));

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-investigationNeeds more investigation to identify if it is a bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions