Documentation ¶
Index ¶
- func AddAutomaticRoleGrants(id string, email string) error
- func AddUserRole(id string, role string) error
- func ConstructSafeURL(scheme string, host string, path string, queryParams map[string]string) (string, error)
- func ConstructURLQuery(u *url.URL, params map[string]string)
- func GetUserInfo(id string) (*models.UserInfo, error)
- func GetUserRoles(id string, create_user bool) ([]string, error)
- func Initialize() error
- func MakeToken(user_info *models.UserInfo, roles []string) (string, error)
- func RemoveUserRole(id string, role string) error
- func SendUserInfo(user_info *models.UserInfo) error
- type GitHubOAuthProvider
- func (provider *GitHubOAuthProvider) Authorize(code string, redirect_uri string) error
- func (provider *GitHubOAuthProvider) GetAuthorizationRedirect(redirect_uri string) (string, error)
- func (provider *GitHubOAuthProvider) GetUserInfo() (*models.UserInfo, error)
- func (provider *GitHubOAuthProvider) IsVerifiedUser() bool
- type GoogleOAuthProvider
- func (provider *GoogleOAuthProvider) Authorize(code string, redirect_uri string) error
- func (provider *GoogleOAuthProvider) GetAuthorizationRedirect(redirect_uri string) (string, error)
- func (provider *GoogleOAuthProvider) GetUserInfo() (*models.UserInfo, error)
- func (provider *GoogleOAuthProvider) IsVerifiedUser() bool
- type LinkedInOAuthProvider
- func (provider *LinkedInOAuthProvider) Authorize(code string, redirect_uri string) error
- func (provider *LinkedInOAuthProvider) GetAuthorizationRedirect(redirect_uri string) (string, error)
- func (provider *LinkedInOAuthProvider) GetUserInfo() (*models.UserInfo, error)
- func (provider *LinkedInOAuthProvider) IsVerifiedUser() bool
- type OAuthProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAutomaticRoleGrants ¶
Automatically grant staff and admin roles based on user's verified email
func AddUserRole ¶
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 ¶
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 ¶
Given a user ID, fetch the user info corresponding to the ID.
func GetUserRoles ¶
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 Initialize ¶ added in v0.3.0
func Initialize() error
func MakeToken ¶
Generates a signed oauth token with the user's id, email, and roles embedded in the claims
func RemoveUserRole ¶
Removes a role from the user with the specified id
func SendUserInfo ¶
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