service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: NCSA Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const LINKEDIN_USER_INFO_URL = "https://api.linkedin.com/v1/people/~:(id,formatted-name,email-address,first-name,last-name)"

Variables

View Source
var HASHTAG_INVALID_ERR = errors.New("`#` is an invalid character")

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 GetAuthorizeRedirect

func GetAuthorizeRedirect(provider string, redirect_uri string) (string, error)

Return the oauth authorization url for the given provider

func GetEmail

func GetEmail(oauth_token string, provider string) (string, bool, error)

Gets the user's email from the specified oauth provider

func GetFirstName

func GetFirstName(oauth_token string, provider string) (string, error)

Gets the user's first name from the specified oauth provider

func GetGithubEmail

func GetGithubEmail(oauth_token string) (string, bool, error)

Uses a valid oauth token to get the user's primary email

func GetGithubName

func GetGithubName(oauth_token string) (string, error)

Uses a valid oauth token to get the user's name

func GetGithubOauthToken

func GetGithubOauthToken(code string) (string, error)

Uses a valid oauth code to get a valid oauth token for the user

func GetGithubUniqueId

func GetGithubUniqueId(oauth_token string) (string, error)

Uses a valid oauth token to get the user's unique id

func GetGithubUsername

func GetGithubUsername(oauth_token string) (string, error)

Uses a valid oauth token to get the user's username

func GetGoogleEmail

func GetGoogleEmail(oauth_token string) (string, bool, error)

Uses a valid oauth token to get the user's primary email

func GetGoogleFirstName

func GetGoogleFirstName(oauth_token string) (string, error)

Uses a valid oauth token to get the user's first name

func GetGoogleLastName

func GetGoogleLastName(oauth_token string) (string, error)

Uses a valid oauth token to get the user's last name

func GetGoogleOauthToken

func GetGoogleOauthToken(code string, redirect_uri string) (string, error)

Uses a valid oauth code to get a valid oauth token for the user

func GetGoogleUniqueId

func GetGoogleUniqueId(oauth_token string) (string, error)

Uses a valid oauth token to get the user's unique id

func GetGoogleUsername

func GetGoogleUsername(oauth_token string) (string, error)

Uses a valid oauth token to get the user's username

func GetLastName

func GetLastName(oauth_token string, provider string) (string, error)

Gets the user's last name from the specified oauth provider

func GetLinkedinEmail

func GetLinkedinEmail(oauth_token string) (string, bool, error)

Uses a valid OAuth token to get the user's primary email.

func GetLinkedinFirstName

func GetLinkedinFirstName(oauth_token string) (string, error)

Uses a valid OAuth token to get the user's name.

func GetLinkedinLastName

func GetLinkedinLastName(oauth_token string) (string, error)

Uses a valid OAuth token to get the user's last name.

func GetLinkedinOauthToken

func GetLinkedinOauthToken(code string, redirect_uri string) (string, error)

Uses a valid OAuth authorization code to get a valid OAuth token for the user.

func GetLinkedinUniqueId

func GetLinkedinUniqueId(oauth_token string) (string, error)

Uses a valid OAuth token to get the user's unique id.

func GetLinkedinUsername

func GetLinkedinUsername(oauth_token string) (string, error)

Uses a valid OAuth token to get the user's username.

func GetOauthToken

func GetOauthToken(code string, provider string, redirect_uri string) (string, error)

Converts an oauth code to an oauth token for the specified provider

func GetUniqueId

func GetUniqueId(oauth_token string, provider string) (string, error)

Gets the user's unique id from the specified oauth provider

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 GetUsername

func GetUsername(oauth_token string, provider string) (string, error)

Gets the user's username from the specified oauth provider

func MakeToken

func MakeToken(id string, email string, 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(id string, username string, first_name string, last_name string, email string) error

Send basic user info to the user service

Types

This section is empty.

Jump to

Keyboard shortcuts

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