auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIMiddleware

func APIMiddleware(rw http.ResponseWriter, request *http.Request, next http.HandlerFunc)

APIMiddleware authenticates API requests

func CLIFlags

func CLIFlags() []cli.Flag

CLIFlags return the auth configuration CLI flags

func CreateJWTToken

func CreateJWTToken(user User) (string, error)

CreateJWTToken creates a JWT token for the provided user

func CreateUser

func CreateUser(db *gorm.DB, user *User) (bool, error)

CreateUser creates a Brizo specific user without forcing any validation on the input

func DeleteInvitedUser

func DeleteInvitedUser(db *gorm.DB, id string) (bool, error)

DeleteInvitedUser will delete an existing invitee based on his/her github username

func GenerateRandomString

func GenerateRandomString(length int) string

GenerateRandomString will provide a [0-9a-Z] string of a specified length.

func GetOAuthStateString

func GetOAuthStateString() (oauthStateString string)

GetOAuthStateString provides a randomized string to prevent csrf

func GithubUserAllowed

func GithubUserAllowed(db *gorm.DB, username string) bool

GithubUserAllowed will determine if the provided username from Github is allowed

func HydrateOAuthConfig

func HydrateOAuthConfig(oauthConf *oauth2.Config)

HydrateOAuthConfig is used to set the ClientID & ClientSecret at runtime so that we can load them via the cli config values

func IsFirstUser

func IsFirstUser(db *gorm.DB) bool

IsFirstUser will determine if any users have registered yet

func UpdateUser

func UpdateUser(db *gorm.DB, user *User) (bool, error)

UpdateUser updates an existing Brizo user based on his/her username

func ValidateJWTToken

func ValidateJWTToken(token string) bool

ValidateJWTToken determines if the provided token is valid

func ValidatePersonalAccessToken

func ValidatePersonalAccessToken(token string) bool

ValidatePersonalAccessToken check that a valid access token exists in the database.

Types

type CreateUserForm

type CreateUserForm struct {
	Username string
}

CreateUserForm represents a new user form

func (*CreateUserForm) FieldMap

func (form *CreateUserForm) FieldMap(req *http.Request) binding.FieldMap

FieldMap is used to bind CreateUserForm to a request

type OAuthCallbackForm

type OAuthCallbackForm struct {
	Code  string
	State string
}

OAuthCallbackForm represents a Github OAuth callback

func (*OAuthCallbackForm) FieldMap

func (form *OAuthCallbackForm) FieldMap(req *http.Request) binding.FieldMap

FieldMap is used to bind OAuthCallbackForm to a request

type User

type User struct {
	database.Model
	Username       string `gorm:"not null;unique_index" json:"username"`
	Name           string `json:"name"`
	Email          string `json:"email"`
	GithubUsername string `json:"github_username"`
	GithubToken    string `json:"github_token"`
}

User represents a Brizo user

func BuildUserFromGithubUser

func BuildUserFromGithubUser(githubUser *githuboauth.User, email string, token string) User

BuildUserFromGithubUser handles the checks needed to build a brizo user from possible github user attributes.

func CreateNewGithubUser

func CreateNewGithubUser(db *gorm.DB, githubUser *githuboauth.User, email string, token string) (User, error)

CreateNewGithubUser takes oauth response values and creates a new Brizo user

func GetInvitedUsers

func GetInvitedUsers(db *gorm.DB) ([]User, error)

GetInvitedUsers will provide a slice of all of the Users who have been invited to Brizo, but have yet to authenticate with Github.

type ValidateJWTForm

type ValidateJWTForm struct {
	Token string
}

ValidateJWTForm represents a json request to validate a token

func (*ValidateJWTForm) FieldMap

func (form *ValidateJWTForm) FieldMap(req *http.Request) binding.FieldMap

FieldMap to map form values to a struct

Jump to

Keyboard shortcuts

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