token

package
v0.0.0-...-51a7f25 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package token manages the Access token.

Index

Constants

View Source
const (
	SuffixSecond                    = "s"
	ErrMSGNotEnoughArgs             = "At least one scope should be present"
	ErrMSGUnableToGetClientCreds    = "Unable to get Client credentials"
	ErrMSGUnableToGetAccessToken    = "Unable to get access token for scopes: %v"
	ErrMSGUnableToParseExpireTime   = "Unable parse expiresIn time"
	ErrMsgUnableToParseRequestBody  = "unable to parse request body: %s"
	ErrMsgUnableToCreateRequestBody = "unable to create request body: %s"
	GenerateAccessToken             = "Generating access Token"
	DynamicClientRegMsg             = "Dynamic Client Reg"
	RefreshTokenContext             = "Refresh token"
	Context                         = "/token"
	UserName                        = "username"
	Password                        = "password"
	GrantPassword                   = "password"
	GrantRefreshToken               = "refresh_token"
	GrantType                       = "grant_type"
	Scope                           = "scope"
	RefreshToken                    = "refresh_token"
	ScopeSubscribe                  = "apim:subscribe"
	ScopeAPIView                    = "apim:api_view"
	LogKeyAT                        = "access-token"
	LogKeyRT                        = "refresh-token"
	LogKeyExpiresIn                 = "expires in"

	// CallBackURL is a dummy value
	CallBackURL = "www.dummy.com"

	// ClientName for dynamic client registration
	ClientName = "apim_service_broker"

	// DynamicClientRegGrantType for dynamic client registration
	DynamicClientRegGrantType = "password refresh_token"

	// Owner for dynamic client registration
	Owner = "admin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicCredentials

type BasicCredentials struct {
	Username string
	Password string
}

BasicCredentials represents the username and Password.

type DynamicClientRegReq

type DynamicClientRegReq struct {
	CallbackURL string `json:"callbackUrl"`
	ClientName  string `json:"clientName"`
	Owner       string `json:"owner"`
	GrantType   string `json:"grantType"`
	SaasApp     bool   `json:"saasApp"`
}

DynamicClientRegReq represents the request for Dynamic client request body.

type DynamicClientRegResBody

type DynamicClientRegResBody struct {
	CallbackURL       string `json:"callBackURL"`
	JSONString        string `json:"jsonString"`
	ClientName        string `json:"clientName"`
	ClientID          string `json:"clientId"`
	ClientSecret      string `json:"clientSecret"`
	IsSaasApplication bool   `json:"isSaasApplication"`
}

DynamicClientRegResBody represents the message body for Dynamic client registration response body.

type Manager

type Manager interface {
	// Init initialize the Token Manager. Generate token for the given scopes.
	// Must run before using the Token Manager.
	Init(scopes []string)

	// Token method returns an access token and any error occurred.
	Token() (string, error)
}

Manager interface manages the token for a set of given scopes.

type PasswordRefreshTokenGrantManager

type PasswordRefreshTokenGrantManager struct {
	TokenEndpoint                    string
	DynamicClientEndpoint            string
	DynamicClientRegistrationContext string
	UserName                         string
	Password                         string
	// contains filtered or unexported fields
}

PasswordRefreshTokenGrantManager is used to manage Access token using password and refresh_token grant type. Holds access token for the given scopes and regenerate token using refresh token if the access token is expired.

func (*PasswordRefreshTokenGrantManager) Init

func (m *PasswordRefreshTokenGrantManager) Init(scopes []string)

Init initialize the Token Manager. Generate token for the given scopes. Must run before using the Token Manager.

func (*PasswordRefreshTokenGrantManager) Token

Token method returns an access token and any error occurred.

type Resp

type Resp struct {
	Scope        string `json:"scope"`
	TokenTypes   string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	AccessToken  string `json:"access_token"`
}

Resp represents the message body of the token api response.

Jump to

Keyboard shortcuts

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