auth

package
v0.0.0-...-0d95af9 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const DroneSessionCookie = "user_sess"

DroneSessionCookie holds the name of the Cookie Drone sets in the browser

View Source
const DroneSessionCookieType = "sess"

DroneSessionCookieType is the Drone token type used for browser sessions

View Source
const DroneUserCookieType = "user"

DroneUserCookieType is the Drone token type used for API sessions

Variables

View Source
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 Auth0Handler

func Auth0Handler(c *gin.Context)

Auth0Handler handles auth

func DelCookie

func DelCookie(w http.ResponseWriter, r *http.Request, name string)

DelCookie deletes a cookie.

func GenerateToken

func GenerateToken(c *gin.Context)

GenerateToken generates token from context TODO: it should be possible to generate tokens via a token (not just session cookie)

func Init

func Init()

Init initialize the auth

func IsEnabled

func IsEnabled() bool

IsEnabled checks if the auth is enabled

func IsHttps

func IsHttps(r *http.Request) bool

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

func SetCookie

func SetCookie(w http.ResponseWriter, r *http.Request, name, value string)

SetCookie writes the cookie value.

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

func (BanzaiUserStorer) Save

func (bus BanzaiUserStorer) Save(schema *auth.Schema, context *auth.Context) (user interface{}, userID string, err error)

Save differs from the default UserStorer.Save() in that it extracts Token and Login and saves to Drone DB as well

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

func (DroneUser) TableName

func (DroneUser) TableName() string

TableName sets DroneUser's table name

type GithubExtraInfo

type GithubExtraInfo struct {
	Login string
	Token string
}

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

type User

type User struct {
	gorm.Model
	Name  string `form:"name"`
	Email string `form:"email"`
	Login string `form:"login"`
	Image string `form:"image"`
}

User struct

Jump to

Keyboard shortcuts

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