authentication

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SessionKey = "ginoauthgh"
	UserKey    = "user"
	StateKey   = "state"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider added in v1.2.0

type Provider interface {
	// Session returns the middleware that loads the cookie session of the given name.
	Session(name string) gin.HandlerFunc
	// SessionHandler returns the guard that lets signed-in users pass.
	SessionHandler() gin.HandlerFunc
	// Routes registers the sign in, sign out and session routes.
	Routes(r *gin.Engine)
}

Provider is one way to sign in: it owns the session store and brings the session middleware, the guard for the authenticated routes and its routes.

type User

type User struct {
	// ID is the id of the hub user (models.User.ID). It is the only part of
	// the session that identifies the user; the other fields are labels.
	ID      uint   `json:"id"`
	Login   string `json:"login"`
	Name    string `json:"name"`
	Email   string `json:"email"`
	Company string `json:"company"`
	URL     string `json:"url"`
	Role    string `json:"role"`
}

User is the signed-in user of a request.

Directories

Path Synopsis
Package github signs users in with their GitHub account.
Package github signs users in with their GitHub account.
Package oauth2 signs users in with any OAuth2 provider that has a user endpoint.
Package oauth2 signs users in with any OAuth2 provider that has a user endpoint.
Package oauthflow is the OAuth2 authorization-code sign in shared by the GitHub and the generic OAuth2 provider.
Package oauthflow is the OAuth2 authorization-code sign in shared by the GitHub and the generic OAuth2 provider.
flowtest
Package flowtest runs the sign in scenarios every OAuth2 provider must pass against a fake identity provider.
Package flowtest runs the sign in scenarios every OAuth2 provider must pass against a fake identity provider.
Package password signs users in with an email address and a password.
Package password signs users in with an email address and a password.
Package usersession keeps the signed-in user in a cookie session.
Package usersession keeps the signed-in user in a cookie session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL