auth

package
v0.0.0-...-6d3478e Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAuthorization

func ParseAuthorization(val string) (authType string, token string, err error)

ParseAuthorization returns the scheme and token of the Authorization string if it's valid.

func ParseToken

func ParseToken(val string) (userID string, token string, err error)

ParseToken parses the base64 encoded token, which it returns the associated userID and session token.

Types

type Auth

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

Auth defines a structure which allows us properly retrieve oauth authentication data from the OAuth2 api.

func New

func New(cred Credential, endpoints oauth2.Endpoint, redirectURL string) *Auth

New returns a new instance of OAuth.

func (*Auth) AuthorizeFromUser

func (a *Auth) AuthorizeFromUser(code string) (*http.Client, Token, error)

AuthorizeFromUser takes the code retrieved from the users login process and attempts to retrieve a access token from the configuration.

func (*Auth) LoginURL

func (a *Auth) LoginURL(state string, xs ...oauth2.AuthCodeOption) string

LoginURL returns the login URL for redirect users to login into acct to provide access token for API requests.

type Credential

type Credential struct {
	ClientID     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret"`
	Scopes       []string `json:"scopes"`
}

Credential defines a struct which holds clientID and clientSecret which are used by oauths.

type Token

type Token struct {
	Type         string    `json:"type"`
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	Expires      time.Time `json:"expires"`
}

Token defines the data returned from a OAuth op.

func (Token) Fields

func (t Token) Fields() map[string]interface{}

Fields returns the given fields as a map.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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