auth

package
v4.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UPLOAD_USER_EMAIL = "upload"

Variables

This section is empty.

Functions

func FakeOauthConfig

func FakeOauthConfig() *oauth2.Config

Types

type Authenticator

type Authenticator interface {
	// AuthenticateRequest takes an HTTP request and
	// attempts to authenticate it.
	// It returns the email address of the authenticated
	// user, or an error.
	// TODO: maybe this should be Authenticate(string) (string, error)
	// Taking the Authorization header and returning the email address
	AuthenticateRequest(*http.Request) (string, string, error)
	IsRefreshTokenValid(string) (bool, error, error)
}

type FakeAuthenticator

type FakeAuthenticator struct {
	MockAuthenticateRequest func(r *http.Request) (string, string, error)
	MockIsRefreshTokenValid func(string) (bool, error, error)
}

func (FakeAuthenticator) AuthenticateRequest

func (f FakeAuthenticator) AuthenticateRequest(r *http.Request) (string, string, error)

func (FakeAuthenticator) IsRefreshTokenValid

func (f FakeAuthenticator) IsRefreshTokenValid(refreshToken string) (bool, error, error)

type FakeOAuthClient

type FakeOAuthClient struct {
	MockAuthCodeURL func(string, ...oauth2.AuthCodeOption) string
	MockExchange    func(context.Context, string) (*oauth2.Token, error)
}

func (*FakeOAuthClient) AuthCodeURL

func (c *FakeOAuthClient) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string

func (*FakeOAuthClient) Exchange

func (c *FakeOAuthClient) Exchange(ctx context.Context, code string) (*oauth2.Token, error)

type GoogleAuthenticator

type GoogleAuthenticator struct {
	OAuthClient            OAuthClient
	SharedSecret           string
	TrustedUserEmailDomain string
}

func (GoogleAuthenticator) AuthenticateRequest

func (g GoogleAuthenticator) AuthenticateRequest(r *http.Request) (string, string, error)

func (GoogleAuthenticator) IsRefreshTokenValid

func (g GoogleAuthenticator) IsRefreshTokenValid(refreshToken string) (bool, error, error)

IsRefreshTokenValid checks if a refresh token is valid by requesting a new access token with it. The first return parameter will return true only if the token is currently valid, i.e. the user has not been suspended or revoked their token. The second return parameter is an error that is populated only if there has been an error when attempting to determine if the token is valid. The third return parameter is an error that is populated only if the token is not currently valid, so can be used to determine the reason for its invalidity.

type GoogleOAuthClient

type GoogleOAuthClient struct {
	Config *oauth2.Config
}

func (GoogleOAuthClient) LookupAccessToken

func (g GoogleOAuthClient) LookupAccessToken(refreshToken string) (string, error)

type IntegrationTestOAuthClient

type IntegrationTestOAuthClient struct{}

IntegrationTestOAuthClient is used for integration tests

func (IntegrationTestOAuthClient) LookupAccessToken

func (f IntegrationTestOAuthClient) LookupAccessToken(refreshToken string) (string, error)

type OAuthClient

type OAuthClient interface {
	// LookupAccessToken takes an access token
	// and returns the email address associated
	// with it
	LookupAccessToken(string) (string, error)
}

Jump to

Keyboard shortcuts

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