providers

package
v0.0.0-...-3c3ec8e Latest Latest
Warning

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

Go to latest
Published: May 2, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPermissionDenied = errors.New("permission denied")

ErrPermissionDenied may be returned from Redeem() to indicate the user is not allowed to login.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	Data() *ProviderData

	ReviewUser(name, accessToken, host string) error
	GetEmailAddress(*SessionState) (string, error)
	Redeem(*url.URL, string, string) (*SessionState, error)
	ValidateGroup(string) bool
	ValidateSessionState(*SessionState) bool
	GetLoginRedirectURL(loginURL url.URL, redirectURI, state string) string
	RefreshSessionIfNeeded(*SessionState) (bool, error)
	SessionFromCookie(string, *cookie.Cipher) (*SessionState, error)
	CookieForSession(*SessionState, *cookie.Cipher) (string, error)
	ValidateRequest(*http.Request) (*SessionState, error)
	GetLoginURL() (*url.URL, error)
	GetRedeemURL() (*url.URL, error)
}

type ProviderData

type ProviderData struct {
	ProviderName string
	ClientID     string
	ClientSecret string
	// Config* attributes are set in the options, if set, these endpoints won't
	// be refetched
	ConfigLoginURL    *url.URL
	ConfigRedeemURL   *url.URL
	ValidateURL       *url.URL
	ProfileURL        *url.URL
	ProtectedResource *url.URL
	Scope             string
	ApprovalPrompt    string
}

func (*ProviderData) CookieForSession

func (p *ProviderData) CookieForSession(s *SessionState, c *cookie.Cipher) (string, error)

CookieForSession serializes a session state for storage in a cookie

func (*ProviderData) Data

func (p *ProviderData) Data() *ProviderData

func (*ProviderData) GetEmailAddress

func (p *ProviderData) GetEmailAddress(s *SessionState) (string, error)

func (*ProviderData) GetLoginRedirectURL

func (p *ProviderData) GetLoginRedirectURL(loginURL url.URL, redirectURI, state string) string

GetLoginRedirectURL with typical oauth parameters

func (*ProviderData) GetLoginURL

func (p *ProviderData) GetLoginURL() (*url.URL, error)

func (*ProviderData) GetRedeemURL

func (p *ProviderData) GetRedeemURL() (*url.URL, error)

func (*ProviderData) Redeem

func (p *ProviderData) Redeem(redeemURL *url.URL, redirectURL, code string) (s *SessionState, err error)

func (*ProviderData) RefreshSessionIfNeeded

func (p *ProviderData) RefreshSessionIfNeeded(s *SessionState) (bool, error)

RefreshSessionIfNeeded

func (*ProviderData) ReviewUser

func (p *ProviderData) ReviewUser(name, accessToken, host string) error

func (*ProviderData) SessionFromCookie

func (p *ProviderData) SessionFromCookie(v string, c *cookie.Cipher) (s *SessionState, err error)

SessionFromCookie deserializes a session from a cookie value

func (*ProviderData) ValidateGroup

func (p *ProviderData) ValidateGroup(email string) bool

ValidateGroup validates that the provided email exists in the configured provider email group(s).

func (*ProviderData) ValidateRequest

func (p *ProviderData) ValidateRequest(_ *http.Request) (*SessionState, error)

func (*ProviderData) ValidateSessionState

func (p *ProviderData) ValidateSessionState(s *SessionState) bool

type SessionState

type SessionState struct {
	AccessToken  string
	ExpiresOn    time.Time
	RefreshToken string
	Email        string
	User         string
	Groups       []string
}

func DecodeSessionState

func DecodeSessionState(v string, c *cookie.Cipher) (s *SessionState, err error)

func (*SessionState) EncodeSessionState

func (s *SessionState) EncodeSessionState(c *cookie.Cipher) (string, error)

func (*SessionState) EncryptedString

func (s *SessionState) EncryptedString(c *cookie.Cipher) (string, error)

func (*SessionState) IsExpired

func (s *SessionState) IsExpired() bool

func (*SessionState) String

func (s *SessionState) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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