Documentation ¶
Overview ¶
Package chistd includes common utilities and functions for setting up and using go-chi.
Index ¶
- Constants
- func AddDefaultMiddlewares(router chi.Router, opts DefaultMiddlewareOptions)
- func AddNosurfMiddleware(cfg *webstd.CSRF, router chi.Router)
- func AddStaticRoutes(logger *zap.Logger, router chi.Router, staticFS embed.FS) error
- func NewRouterWithDefaultMiddlewares(opts DefaultMiddlewareOptions) chi.Router
- type DefaultMiddlewareOptions
- type OIDCHandlerContext
Constants ¶
const ( // URL paths OIDCRegisterPath = "/oidc/register" OIDCLoginPath = "/oidc/login" OIDCLogoutPath = "/oidc/logout" OIDCCallbackPath = "/oidc/callback" // Session keys IDTokenSessionKey = "id_token" AccessTokenSessionKey = "access_token" AccessTokenExpirySessionKey = "access_token_expiry" RefreshTokenSessionKey = "refresh_token" UserProfileSessionKey = "profile" ContinueToURLSessionKey = "continue_to" PKCECodeVerifierSessionKey = "pkce_code_verifier" )
Variables ¶
This section is empty.
Functions ¶
func AddDefaultMiddlewares ¶
func AddDefaultMiddlewares(router chi.Router, opts DefaultMiddlewareOptions)
AddDefaultMiddlewares adds all the chi middlewares that we want for applied to all requests.
func AddNosurfMiddleware ¶
AddNosurfMiddleware will add the nosurf middleware into the chi stack.
func AddStaticRoutes ¶
AddStaticRoutes creates routes for static assets. This will directly serve static files under the /static route, but also serve some favicon related files from the root path.
func NewRouterWithDefaultMiddlewares ¶
func NewRouterWithDefaultMiddlewares(opts DefaultMiddlewareOptions) chi.Router
NewRouterWithDefaultMiddlewares returns a new go-chi router that has a set of recommended default routers configured.
Types ¶
type OIDCHandlerContext ¶
type OIDCHandlerContext[T any] struct { // contains filtered or unexported fields }
func NewOIDCHandlerContext ¶
func NewOIDCHandlerContext[T any]( logger *zap.Logger, auth *webstd.Authenticator, sessMgr *scs.SessionManager, homePath string, ) *OIDCHandlerContext[T]
NewOIDCHandlerContext returns a new handler context for the OIDC pages. The generic type parameter represents the profile struct to marshal the ID token claims to.
func (OIDCHandlerContext[T]) AddOIDCHandlerRoutes ¶
func (h OIDCHandlerContext[T]) AddOIDCHandlerRoutes(router chi.Router)
AddOIDCHandlerRoutes will add a group of routes that can be used to implement OIDC client protocol to manage authentication into an existing go-chi based web app. Note that this depends on the following two middlewares: - github.com/alexedwards/scs/v2 - github.com/ory/nosurf