Documentation
¶
Overview ¶
Package oidc provides HTTP authentication using OpenID Connect via goth.
Index ¶
- Constants
- func AccessTokenFromContext(ctx context.Context) *oauth2.Token
- func ContextWithAccessToken(ctx context.Context, token *oauth2.Token) context.Context
- func ContextWithOIDCUserInfo(ctx context.Context, userInfo *goth.User) context.Context
- func OIDCUserInfoFromContext(ctx context.Context) *goth.User
- type Handler
- func (h *Handler) AuthRequest(r *http.Request) (stdctx.Context, error)
- func (h *Handler) AuthStart() http.HandlerFunc
- func (h *Handler) AuthWrapper(next http.HandlerFunc) http.HandlerFunc
- func (h *Handler) Callback() http.HandlerFunc
- func (h *Handler) LogoutHandler() http.HandlerFunc
- func (h *Handler) Middleware(next http.Handler) http.Handler
- type SessionData
Constants ¶
const ( // SessionCookieName is the name of the cookie used to store the OIDC session. SessionCookieName = "dioad_session" // PreAuthRefererCookieName is the name of the cookie used to store the referer URL before authentication. PreAuthRefererCookieName = "auth_referer" )
Variables ¶
This section is empty.
Functions ¶
func AccessTokenFromContext ¶
AccessTokenFromContext returns the access token from the provided context. It returns a nil value if no token is found.
func ContextWithAccessToken ¶
ContextWithAccessToken returns a new context with the provided access token.
func ContextWithOIDCUserInfo ¶
ContextWithOIDCUserInfo returns a new context with the provided OIDC user info.
Types ¶
type Handler ¶
type Handler struct {
CookieStore sessions.Store
LoginPath string
LogoutPath string
CallbackDefaultRedirect string
HomePath string
}
Handler implements OIDC-based authentication using the gothic library.
func NewHandler ¶
NewHandler configures OIDC providers and returns a handler.
func (*Handler) AuthRequest ¶
AuthRequest authenticates an HTTP request by checking for a valid OIDC session cookie.
func (*Handler) AuthStart ¶
func (h *Handler) AuthStart() http.HandlerFunc
AuthStart returns an HTTP handler function that starts the OIDC authentication flow.
func (*Handler) AuthWrapper ¶
func (h *Handler) AuthWrapper(next http.HandlerFunc) http.HandlerFunc
AuthWrapper wraps an HTTP handler function with OIDC authentication. If the user is not authenticated, they are redirected to the login path.
func (*Handler) Callback ¶
func (h *Handler) Callback() http.HandlerFunc
Callback handles provider callbacks.
func (*Handler) LogoutHandler ¶
func (h *Handler) LogoutHandler() http.HandlerFunc
LogoutHandler clears authentication state and redirects to login.