Documentation
¶
Index ¶
- Constants
- Variables
- func Auth0Handler(c *gin.Context)
- func DelCookie(w http.ResponseWriter, r *http.Request, name string)
- func GenerateToken(c *gin.Context)
- func Init()
- func IsEnabled() bool
- func IsHttps(r *http.Request) bool
- func NewGithubAuthorizeHandler(provider *githubauth.GithubProvider) func(context *auth.Context) (*claims.Claims, error)
- func SetCookie(w http.ResponseWriter, r *http.Request, name, value string)
- type BanzaiSessionStorer
- type BanzaiUserStorer
- type DroneClaims
- type DroneUser
- type GithubExtraInfo
- type ScopedClaims
- type TokenStore
- type User
Constants ¶
const DroneSessionCookie = "user_sess"
DroneSessionCookie holds the name of the Cookie Drone sets in the browser
const DroneSessionCookieType = "sess"
DroneSessionCookieType is the Drone token type used for browser sessions
const DroneUserCookieType = "user"
DroneUserCookieType is the Drone token type used for API sessions
Variables ¶
var ( RedirectBack *redirect_back.RedirectBack Auth *auth.Auth Authority *authority.Authority // JwtIssuer ("iss") claim identifies principal that issued the JWT JwtIssuer string // JwtAudience ("aud") claim identifies the recipients that the JWT is intended for JwtAudience string )
Init authorization
Functions ¶
func DelCookie ¶
func DelCookie(w http.ResponseWriter, r *http.Request, name string)
DelCookie deletes a cookie.
func GenerateToken ¶
GenerateToken generates token from context TODO: it should be possible to generate tokens via a token (not just session cookie)
func IsHttps ¶
IsHttps is a helper function that evaluates the http.Request and returns True if the Request uses HTTPS. It is able to detect, using the X-Forwarded-Proto, if the original request was HTTPS and routed through a reverse proxy with SSL termination.
func NewGithubAuthorizeHandler ¶
func NewGithubAuthorizeHandler(provider *githubauth.GithubProvider) func(context *auth.Context) (*claims.Claims, error)
NewGithubAuthorizeHandler handler for Github auth
Types ¶
type BanzaiSessionStorer ¶
type BanzaiSessionStorer struct { auth.SessionStorer SignedStringBytes []byte }
BanzaiSessionStorer stores the banzai session
func (*BanzaiSessionStorer) SignedTokenWithDrone ¶
func (sessionStorer *BanzaiSessionStorer) SignedTokenWithDrone(claims *DroneClaims) (string, error)
SignedTokenWithDrone generate signed token with Claims
func (*BanzaiSessionStorer) Update ¶
func (sessionStorer *BanzaiSessionStorer) Update(w http.ResponseWriter, req *http.Request, claims *claims.Claims) error
Update updates the BanzaiSessionStorer
type BanzaiUserStorer ¶
type BanzaiUserStorer struct { auth.UserStorer // contains filtered or unexported fields }
BanzaiUserStorer struct
type DroneClaims ¶
type DroneClaims struct { *claims.Claims Type string `json:"type,omitempty"` Text string `json:"text,omitempty"` }
DroneClaims struct to store the drone claim related things
type DroneUser ¶
type DroneUser struct { ID int64 `gorm:"column:user_id;primary_key"` Login string `gorm:"column:user_login"` Token string `gorm:"column:user_token"` Secret string `gorm:"column:user_secret"` Expiry int64 `gorm:"column:user_expiry"` Email string `gorm:"column:user_email"` Image string `gorm:"column:user_avatar"` Active bool `gorm:"column:user_active"` Admin bool `gorm:"column:user_admin"` Hash string `gorm:"column:user_hash"` Synced int64 `gorm:"column:user_synced"` }
DroneUser struct
type GithubExtraInfo ¶
GithubExtraInfo struct for github credentials
type ScopedClaims ¶
type ScopedClaims struct { jwt.StandardClaims Scope string `json:"scope,omitempty"` // Drone Type string `json:"type,omitempty"` Text string `json:"text,omitempty"` }
ScopedClaims struct to store the scoped claim related things
type TokenStore ¶
type TokenStore interface { Store(string, string) error Lookup(string, string) (bool, error) Revoke(string, string) error List(string) ([]string, error) }
TokenStore is general interface for storing access tokens
func NewInMemoryTokenStore ¶
func NewInMemoryTokenStore() TokenStore
NewInMemoryTokenStore is a basic in-memory TokenStore implementation (thread-safe)
func NewVaultTokenStore ¶
func NewVaultTokenStore() TokenStore
NewVaultTokenStore creates a new Vault backed token store