feat/handlers #2

Merged
jd merged 9 commits from feat/handlers into main 2026-02-08 14:22:33 -05:00
Owner
No description provided.
jd added 9 commits 2026-02-08 14:22:21 -05:00
- implement Auth struct with cookie-based session management
- integrate zitadel/oidc v3 for OpenID Connect flow
- support PKCE and JWT profile authentication methods
- add configurable TLS, timeout, and cookie security options
- include user handler interface for custom user logic
Introduce a new HTTP handler that starts the OIDC flow and generates a
unique state value for each request. The handler uses the OIDC
provider and optional URL options to construct the authentication URL.
Add a new callback handler that exchanges the authorization code for tokens, sets refresh and ID token cookies, and redirects the user to the original referrer or root. This introduces the `marshalToken` and `setTokenCookies` helpers and exposes `CallbackHandler()` for use in the authentication flow.
This change introduces a generic `Auth[I any]` type that allows the user ID to be any comparable type. The `UserHandler` interface is updated to work with this generic ID, and new middleware helpers are added to expose authentication and authorization information in request contexts. Existing handlers are updated to use the new generic signatures.

BREAKING CHANGE: Auth struct and its methods now require a type parameter for the user ID, and the UserHandler interface has been replaced with a generic version. Existing code must be updated to provide the appropriate type argument.
Add a `Paths` struct to the configuration to allow custom login, logout, redirect, unauthorized, and home URLs. Update all redirect logic in callback, logout, and middleware to use these configurable paths. Adjust default configuration and validation to include the new paths. This refactor improves flexibility without changing public API.
The cookie names are now defined in a dedicated `CookieNames` struct and the
context key type has been changed from a string to a custom `ctxKey` type to
avoid key collisions. This refactor cleans up the auth package and improves
type safety for context values.
This change introduces a new `Insecure` struct to separate host and provider insecure flags, adds granular path configuration via `PathOption` helpers, and refactors middleware to handle token verification and refreshing more robustly. It also updates cookie handling and login/logout logic to use the new configuration structure.
jd merged commit b87abfc8a5 into main 2026-02-08 14:22:33 -05:00
jd deleted branch feat/handlers 2026-02-08 14:22:33 -05:00
jd referenced this pull request from a commit 2026-02-08 14:22:35 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jd/simple-auth!2
No description provided.