Documentation ¶
Index ¶
- func APIMiddleware(rw http.ResponseWriter, request *http.Request, next http.HandlerFunc)
- func CLIFlags() []cli.Flag
- func CreateJWTToken(user User) (string, error)
- func CreateUser(db *gorm.DB, user *User) (bool, error)
- func DeleteInvitedUser(db *gorm.DB, id string) (bool, error)
- func GenerateRandomString(length int) string
- func GetOAuthStateString() (oauthStateString string)
- func GithubUserAllowed(db *gorm.DB, username string) bool
- func HydrateOAuthConfig(oauthConf *oauth2.Config)
- func IsFirstUser(db *gorm.DB) bool
- func UpdateUser(db *gorm.DB, user *User) (bool, error)
- func ValidateJWTToken(token string) bool
- func ValidatePersonalAccessToken(token string) bool
- type CreateUserForm
- type OAuthCallbackForm
- type User
- type ValidateJWTForm
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 CreateJWTToken ¶
CreateJWTToken creates a JWT token for the provided user
func CreateUser ¶
CreateUser creates a Brizo specific user without forcing any validation on the input
func DeleteInvitedUser ¶
DeleteInvitedUser will delete an existing invitee based on his/her github username
func GenerateRandomString ¶
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 ¶
GithubUserAllowed will determine if the provided username from Github is allowed
func HydrateOAuthConfig ¶
HydrateOAuthConfig is used to set the ClientID & ClientSecret at runtime so that we can load them via the cli config values
func IsFirstUser ¶
IsFirstUser will determine if any users have registered yet
func UpdateUser ¶
UpdateUser updates an existing Brizo user based on his/her username
func ValidateJWTToken ¶
ValidateJWTToken determines if the provided token is valid
func ValidatePersonalAccessToken ¶
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
type OAuthCallbackForm ¶
OAuthCallbackForm represents a Github OAuth callback
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
type ValidateJWTForm ¶
type ValidateJWTForm struct {
Token string
}
ValidateJWTForm represents a json request to validate a token