service

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: NCSA Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAutomaticRoleGrants

func AddAutomaticRoleGrants(id string, email string) error

Automatically grant staff and admin roles based on user's verified email

func AddUserRole

func AddUserRole(id string, role string) error

Adds a role to the user with the specified id

func ConstructSafeURL

func ConstructSafeURL(scheme string, host string, path string, queryParams map[string]string) (string, error)
	This function takes in the ingredients to a URL and outputs a string of them all together.
	It also checks for the appearance of "#" anywhere in the query params and throws an error if it is there.
    queryParams is an optional param. nil can be passed in if the url needs no query params.

func ConstructURLQuery

func ConstructURLQuery(u *url.URL, params map[string]string)

A helper function that takes a URL pointer and a map of query params->values, and modifies the URL's RawQuery property with the supplied query params.

func GetUserInfo

func GetUserInfo(id string) (*models.UserInfo, error)

Given a user ID, fetch the user info corresponding to the ID.

func GetUserRoles

func GetUserRoles(id string, create_user bool) ([]string, error)

Get the user's roles by id If the user has no roles and create_user is true they will be assigned the role User This generally occurs the first time the user logs into the service

func GetUsersByRole added in v0.4.0

func GetUsersByRole(role models.Role) ([]string, error)

Returns a list of user ids with a given role

func GetValidRoles added in v0.4.0

func GetValidRoles() []models.Role

Returns a list of valid roles for a user to be assigned

func Initialize added in v0.3.0

func Initialize() error

func MakeToken

func MakeToken(user_info *models.UserInfo, roles []string) (string, error)

Generates a signed oauth token with the user's id, email, and roles embedded in the claims

func RemoveUserRole

func RemoveUserRole(id string, role string) error

Removes a role from the user with the specified id

func SendUserInfo

func SendUserInfo(user_info *models.UserInfo) error

Send basic user info to the user service

Types

type GitHubOAuthProvider added in v0.3.0

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

func NewGitHubOAuth added in v0.3.0

func NewGitHubOAuth() *GitHubOAuthProvider

func (*GitHubOAuthProvider) Authorize added in v0.3.0

func (provider *GitHubOAuthProvider) Authorize(code string, redirect_uri string) error

Exchanges an OAuth code for an OAuth token

func (*GitHubOAuthProvider) GetAuthorizationRedirect added in v0.3.0

func (provider *GitHubOAuthProvider) GetAuthorizationRedirect(redirect_uri string) (string, error)

Returns the url to redirects to for OAuth authorization

func (*GitHubOAuthProvider) GetUserInfo added in v0.3.0

func (provider *GitHubOAuthProvider) GetUserInfo() (*models.UserInfo, error)

Retrieves user info from the OAuth provider

func (*GitHubOAuthProvider) IsVerifiedUser added in v0.3.0

func (provider *GitHubOAuthProvider) IsVerifiedUser() bool

Returns true if the user has a verified email

type GoogleOAuthProvider added in v0.3.0

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

func NewGoogleOAuth added in v0.3.0

func NewGoogleOAuth() *GoogleOAuthProvider

func (*GoogleOAuthProvider) Authorize added in v0.3.0

func (provider *GoogleOAuthProvider) Authorize(code string, redirect_uri string) error

Exchanges an OAuth code for an OAuth token

func (*GoogleOAuthProvider) GetAuthorizationRedirect added in v0.3.0

func (provider *GoogleOAuthProvider) GetAuthorizationRedirect(redirect_uri string) (string, error)

Returns the url to redirects to for OAuth authorization

func (*GoogleOAuthProvider) GetUserInfo added in v0.3.0

func (provider *GoogleOAuthProvider) GetUserInfo() (*models.UserInfo, error)

Retrieves user info from the OAuth provider

func (*GoogleOAuthProvider) IsVerifiedUser added in v0.3.0

func (provider *GoogleOAuthProvider) IsVerifiedUser() bool

Returns true if the user has a verified email

type LinkedInOAuthProvider added in v0.3.0

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

func NewLinkedInOAuth added in v0.3.0

func NewLinkedInOAuth() *LinkedInOAuthProvider

func (*LinkedInOAuthProvider) Authorize added in v0.3.0

func (provider *LinkedInOAuthProvider) Authorize(code string, redirect_uri string) error

Exchanges an OAuth code for an OAuth token

func (*LinkedInOAuthProvider) GetAuthorizationRedirect added in v0.3.0

func (provider *LinkedInOAuthProvider) GetAuthorizationRedirect(redirect_uri string) (string, error)

Returns the url to redirects to for OAuth authorization

func (*LinkedInOAuthProvider) GetUserInfo added in v0.3.0

func (provider *LinkedInOAuthProvider) GetUserInfo() (*models.UserInfo, error)

Retrieves user info from the OAuth provider

func (*LinkedInOAuthProvider) IsVerifiedUser added in v0.3.0

func (provider *LinkedInOAuthProvider) IsVerifiedUser() bool

Returns true if the user has a verified email

type OAuthProvider added in v0.3.0

type OAuthProvider interface {
	GetAuthorizationRedirect(redirect_uri string) (string, error)
	Authorize(code string, redirect_uri string) error
	GetUserInfo() (*models.UserInfo, error)
	IsVerifiedUser() bool
}

func GetOAuthProvider added in v0.3.0

func GetOAuthProvider(provider string) (OAuthProvider, error)

Returns an OAuth provider struct for the requested provider

Jump to

Keyboard shortcuts

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