auth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2017 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorizeDeviceCode

func AuthorizeDeviceCode(ctx context.Context, clientID string, output io.Writer) (token *adal.Token, err error)

AuthorizeDeviceCode runs authentication process by a device code.

func NewToken

func NewToken(filename string) (token *adal.Token, err error)

NewToken reads a file and returns a token in it.

Types

type Authorizer

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

Authorizer provides methods to get an authorization code and refresh it.

func NewAuthorizer

func NewAuthorizer(tenantID, clientID string, redirect *url.URL, state string) (a *Authorizer, err error)

NewAuthorizer creates a new authorizer.

func (*Authorizer) Close

func (a *Authorizer) Close() error

Close authorization process. It must be called.

func (*Authorizer) GetAuthorizeURL

func (a *Authorizer) GetAuthorizeURL() string

GetAuthorizeURL returns a URL which users should access.

func (*Authorizer) RefreshToken

func (a *Authorizer) RefreshToken(token *adal.Token) (newToken *adal.Token, err error)

RefreshToken refreshes a token.

func (*Authorizer) WaitResponse

func (a *Authorizer) WaitResponse(ctx context.Context) (*adal.Token, error)

WaitResponse waits the user acceseses an authorization URL and grants access.

type DeviceCode

type DeviceCode struct {
	UserCode        string `json:"user_code"`
	DeviceCode      string `json:"device_code"`
	VerificationURL string `json:"verification_url"`
	ExpiresIn       string `json:"expires_in"`
	Interval        string `json:"interval"`
	Message         string `json:"message"`
}

DeviceCode defines a structure of a response to obtain a device code.

func GetDeviceCode

func GetDeviceCode(ctx context.Context, clientID string) (code *DeviceCode, err error)

GetDeviceCode gets a device code.

type ManualAuthorizer

type ManualAuthorizer struct {
	AuthorizeURL string
	// contains filtered or unexported fields
}

ManualAuthorizer is an authorizer which gets an authorization code manually.

func NewManualAuthorizer

func NewManualAuthorizer(tenantID, clientID string, redirect *url.URL, state string) (a *ManualAuthorizer)

NewManualAuthorizer creates a new manual authorizer.

func (*ManualAuthorizer) GetAuthorizeURL

func (a *ManualAuthorizer) GetAuthorizeURL() string

GetAuthorizeURL returns a URL where the user should open.

func (*ManualAuthorizer) RefreshToken

func (a *ManualAuthorizer) RefreshToken(token *adal.Token) (newToken *adal.Token, err error)

RefreshToken refreshes the authorization token.

func (*ManualAuthorizer) RequestToken

func (a *ManualAuthorizer) RequestToken(authorizationCode string) (token *adal.Token, err error)

RequestToken requests an authorization token.

type TokenError

type TokenError struct {
	ErrorSummary     string `json:"error"`
	ErrorDescription string `json:"error_description"`
	ErrorCodes       []int  `json:"error_codes"`
	Timestamp        string `json:"timestamp"`
	TraceID          string `json:"trace_id"`
	CorrelationID    string `json:"correlation_id"`
}

TokenError defines errors for a token.

func (*TokenError) Error

func (e *TokenError) Error() string

Error returns a string representing this error.

Jump to

Keyboard shortcuts

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