Skip to content

Expose function for making manual authorization requests with additional query parameters #1331

@kpala

Description

@kpala

Which middleware is the feature for?

@hono/oidc-auth

What is the feature you are proposing?

Hello!

I'm using Keycloak for authentication and user management: https://www.keycloak.org/

I tried using @hono/oidc-auth middleware in this context, which works nicely so far.

The oidc-auth middleware makes an authorization request inside oidcAuthMiddleware function, here's the spot: https://github.com/honojs/middleware/blob/main/packages/oidc-auth/src/index.ts#L461

What I would like to do, is to manually make a similar authorization request call, but with additional query parameters. This matches the Keycloak's "Application initiated action" as described here: https://github.com/keycloak/keycloak-community/blob/main/design/application-initiated-actions.md#flows

For instance, when passing e.g. kc_action=update_profile as one of the query parameters, the authorization endpoint in Keycloak shows a UI for updating the user's profile.

Basically, I'd like to have something like

app.get('/auth/update', (c) => redirectOidcAuth(c, { kc_action: 'update_profile' });

where redirectOidcAuth is extracted from oidcAuthMiddleware into a separate exported function, which also accepts additional query parameters.

At the moment, if I want to achieve this while still using this middleware to handle the redirection callback, I need to copy-paste some code from oidcAuthMiddleware and generateAuthorizationRequestUrl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions