auth

package
v0.0.0-...-29e6843 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSuperUser

func IsSuperUser(superUsers []string, u gimlet.User) bool

IsSuperUser verifies that a given user has super user permissions. A user has these permission if they are in the super users list or if the list is empty, in which case all users are super users.

func LoadUserManager

func LoadUserManager(authConfig evergreen.AuthConfig) (gimlet.UserManager, error)

LoadUserManager is used to check the configuration for authentication and create a UserManager depending on what type of authentication (Crowd or Naive) is used.

func NewCrowdUserManager

func NewCrowdUserManager(conf *evergreen.CrowdConfig) (gimlet.UserManager, error)

NewCrowdUserManager creates a manager for the user and password combination that connects to the crowd service at the given URL.

func NewGithubUserManager

func NewGithubUserManager(g *evergreen.GithubAuthConfig) (gimlet.UserManager, error)

NewGithubUserManager initializes a GithubUserManager with a Salt as randomly generated string used in Github authentication

Types

type CrowdUserManager

type CrowdUserManager struct {
	*crowd.Client
}

CrowdUserManager handles authentication with Atlassian Crowd.

func (*CrowdUserManager) CreateUserToken

func (c *CrowdUserManager) CreateUserToken(username, password string) (string, error)

CreateUserToken creates a user session in crowd. This session token is returned.

func (*CrowdUserManager) GetLoginCallbackHandler

func (*CrowdUserManager) GetLoginCallbackHandler() http.HandlerFunc

func (*CrowdUserManager) GetLoginHandler

func (*CrowdUserManager) GetLoginHandler(string) http.HandlerFunc

func (*CrowdUserManager) GetOrCreateUser

func (*CrowdUserManager) GetOrCreateUser(u gimlet.User) (gimlet.User, error)

func (*CrowdUserManager) GetUserByID

func (*CrowdUserManager) GetUserByID(id string) (gimlet.User, error)

func (*CrowdUserManager) GetUserByToken

func (c *CrowdUserManager) GetUserByToken(_ context.Context, token string) (gimlet.User, error)

GetUserByToken returns the user for the supplied token, or an error if the user is not found.

func (*CrowdUserManager) IsRedirect

func (*CrowdUserManager) IsRedirect() bool

type GithubUserManager

type GithubUserManager struct {
	ClientId               string
	ClientSecret           string
	AuthorizedUsers        []string
	AuthorizedOrganization string
	Salt                   string
}

func (*GithubUserManager) CreateUserToken

func (*GithubUserManager) CreateUserToken(string, string) (string, error)

CreateUserToken is not implemented in GithubUserManager

func (*GithubUserManager) GetLoginCallbackHandler

func (gum *GithubUserManager) GetLoginCallbackHandler() http.HandlerFunc

GetLoginCallbackHandler returns the function that is called when GitHub redirects the user back to Evergreen.

func (*GithubUserManager) GetLoginHandler

func (gum *GithubUserManager) GetLoginHandler(callbackUri string) http.HandlerFunc

GetLoginHandler returns the function that starts oauth by redirecting the user to authenticate with Github

func (*GithubUserManager) GetOrCreateUser

func (*GithubUserManager) GetOrCreateUser(u gimlet.User) (gimlet.User, error)

func (*GithubUserManager) GetUserByID

func (*GithubUserManager) GetUserByID(id string) (gimlet.User, error)

func (*GithubUserManager) GetUserByToken

func (gum *GithubUserManager) GetUserByToken(ctx context.Context, token string) (gimlet.User, error)

GetUserByToken sends the token to Github and gets back a user and optionally an organization. If there are Authorized Users, it checks the authorized usernames against the GitHub user's login If there is no match and there is an organization it checks the user's organizations against the UserManager's Authorized organization string.

func (*GithubUserManager) IsRedirect

func (*GithubUserManager) IsRedirect() bool

type NaiveUserManager

type NaiveUserManager struct {
	// contains filtered or unexported fields
}

NaiveUserManager implements the UserManager interface and has a list of AuthUsers{UserName, DisplayName, Password, Email string} which is stored in the settings configuration file. Note: This use of the UserManager is recommended for dev/test purposes only and users who need high security authentication mechanisms should rely on a different authentication mechanism.

func NewNaiveUserManager

func NewNaiveUserManager(naiveAuthConfig *evergreen.NaiveAuthConfig) (*NaiveUserManager, error)

func (*NaiveUserManager) CreateUserToken

func (b *NaiveUserManager) CreateUserToken(username, password string) (string, error)

CreateUserToken finds the user with the same username and password in its list of users and creates a token that is a combination of the index of the list the user is at, the email address and a hash of the username and password and returns that token.

func (*NaiveUserManager) GetLoginCallbackHandler

func (*NaiveUserManager) GetLoginCallbackHandler() http.HandlerFunc

func (*NaiveUserManager) GetLoginHandler

func (*NaiveUserManager) GetLoginHandler(string) http.HandlerFunc

func (*NaiveUserManager) GetOrCreateUser

func (*NaiveUserManager) GetOrCreateUser(u gimlet.User) (gimlet.User, error)

func (*NaiveUserManager) GetUserByID

func (*NaiveUserManager) GetUserByID(id string) (gimlet.User, error)

func (*NaiveUserManager) GetUserByToken

func (b *NaiveUserManager) GetUserByToken(_ context.Context, token string) (gimlet.User, error)

GetUserByToken does a find by creating a temporary token from the index of the user on the list, the email of the user and a hash of the username and password, checking it against the token string and returning a User if there is a match.

func (*NaiveUserManager) IsRedirect

func (*NaiveUserManager) IsRedirect() bool

Jump to

Keyboard shortcuts

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