oauth2.v3: gopkg.in/oauth2.v3 Index | Files | Directories

package oauth2

import "gopkg.in/oauth2.v3"

Index

Package Files

const.go doc.go generate.go manage.go model.go store.go

type AccessGenerate Uses

type AccessGenerate interface {
    Token(data *GenerateBasic, isGenRefresh bool) (access, refresh string, err error)
}

AccessGenerate generate the access and refresh tokens interface

type AuthorizeGenerate Uses

type AuthorizeGenerate interface {
    Token(data *GenerateBasic) (code string, err error)
}

AuthorizeGenerate generate the authorization code interface

type ClientInfo Uses

type ClientInfo interface {
    GetID() string
    GetSecret() string
    GetDomain() string
    GetUserID() string
}

ClientInfo the client information model interface

type ClientStore Uses

type ClientStore interface {
    // according to the ID for the client information
    GetByID(id string) (ClientInfo, error)
}

ClientStore the client information storage interface

type GenerateBasic Uses

type GenerateBasic struct {
    Client    ClientInfo
    UserID    string
    CreateAt  time.Time
    TokenInfo TokenInfo
    Request   *http.Request
}

GenerateBasic provide the basis of the generated token data

type GrantType Uses

type GrantType string

GrantType authorization model

const (
    AuthorizationCode   GrantType = "authorization_code"
    PasswordCredentials GrantType = "password"
    ClientCredentials   GrantType = "client_credentials"
    Refreshing          GrantType = "refresh_token"
    Implicit            GrantType = "__implicit"
)

define authorization model

func (GrantType) String Uses

func (gt GrantType) String() string

type Manager Uses

type Manager interface {
    // get the client information
    GetClient(clientID string) (cli ClientInfo, err error)

    // generate the authorization token(code)
    GenerateAuthToken(rt ResponseType, tgr *TokenGenerateRequest) (authToken TokenInfo, err error)

    // generate the access token
    GenerateAccessToken(rt GrantType, tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)

    // refreshing an access token
    RefreshAccessToken(tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)

    // use the access token to delete the token information
    RemoveAccessToken(access string) (err error)

    // use the refresh token to delete the token information
    RemoveRefreshToken(refresh string) (err error)

    // according to the access token for corresponding token information
    LoadAccessToken(access string) (ti TokenInfo, err error)

    // according to the refresh token for corresponding token information
    LoadRefreshToken(refresh string) (ti TokenInfo, err error)
}

Manager authorization management interface

type ResponseType Uses

type ResponseType string

ResponseType the type of authorization request

const (
    Code  ResponseType = "code"
    Token ResponseType = "token"
)

define the type of authorization request

func (ResponseType) String Uses

func (rt ResponseType) String() string

type TokenGenerateRequest Uses

type TokenGenerateRequest struct {
    ClientID       string
    ClientSecret   string
    UserID         string
    RedirectURI    string
    Scope          string
    Code           string
    Refresh        string
    AccessTokenExp time.Duration
    Request        *http.Request
}

TokenGenerateRequest provide to generate the token request parameters

type TokenInfo Uses

type TokenInfo interface {
    New() TokenInfo

    GetClientID() string
    SetClientID(string)
    GetUserID() string
    SetUserID(string)
    GetRedirectURI() string
    SetRedirectURI(string)
    GetScope() string
    SetScope(string)

    GetCode() string
    SetCode(string)
    GetCodeCreateAt() time.Time
    SetCodeCreateAt(time.Time)
    GetCodeExpiresIn() time.Duration
    SetCodeExpiresIn(time.Duration)

    GetAccess() string
    SetAccess(string)
    GetAccessCreateAt() time.Time
    SetAccessCreateAt(time.Time)
    GetAccessExpiresIn() time.Duration
    SetAccessExpiresIn(time.Duration)

    GetRefresh() string
    SetRefresh(string)
    GetRefreshCreateAt() time.Time
    SetRefreshCreateAt(time.Time)
    GetRefreshExpiresIn() time.Duration
    SetRefreshExpiresIn(time.Duration)
}

TokenInfo the token information model interface

type TokenStore Uses

type TokenStore interface {
    // create and store the new token information
    Create(info TokenInfo) error

    // delete the authorization code
    RemoveByCode(code string) error

    // use the access token to delete the token information
    RemoveByAccess(access string) error

    // use the refresh token to delete the token information
    RemoveByRefresh(refresh string) error

    // use the authorization code for token information data
    GetByCode(code string) (TokenInfo, error)

    // use the access token for token information data
    GetByAccess(access string) (TokenInfo, error)

    // use the refresh token for token information data
    GetByRefresh(refresh string) (TokenInfo, error)
}

TokenStore the token information storage interface

Directories

PathSynopsis
errors
example/client
example/server
generates
manage
models
server
store
utils/uuid

Package oauth2 imports 2 packages (graph) and is imported by 67 packages. Updated 2020-01-26. Refresh now. Tools for package owners.