base

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package base contains a "Base" client that is used by the external public.Client and confidential.Client. Base holds shared attributes that must be available to both clients and methods that act as shared calls.

Index

Constants

View Source
const (
	// AuthorityPublicCloud is the default AAD authority host
	AuthorityPublicCloud = "https://login.microsoftonline.com/common"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AcquireTokenAuthCodeParameters

type AcquireTokenAuthCodeParameters struct {
	Scopes      []string
	Code        string
	Challenge   string
	RedirectURI string
	AppType     accesstokens.AppType
	Credential  *accesstokens.Credential
}

AcquireTokenAuthCodeParameters contains the parameters required to acquire an access token using the auth code flow. To use PKCE, set the CodeChallengeParameter. Code challenges are used to secure authorization code grants; for more information, visit https://tools.ietf.org/html/rfc7636.

type AcquireTokenOnBehalfOfParameters

type AcquireTokenOnBehalfOfParameters struct {
	Scopes        []string
	Credential    *accesstokens.Credential
	UserAssertion string
}

type AcquireTokenSilentParameters

type AcquireTokenSilentParameters struct {
	Scopes            []string
	Account           shared.Account
	RequestType       accesstokens.AppType
	Credential        *accesstokens.Credential
	IsAppCache        bool
	UserAssertion     string
	AuthorizationType authority.AuthorizeType
}

AcquireTokenSilentParameters contains the parameters to acquire a token silently (from cache).

type AuthResult

type AuthResult struct {
	Account        shared.Account
	IDToken        accesstokens.IDToken
	AccessToken    string
	ExpiresOn      time.Time
	GrantedScopes  []string
	DeclinedScopes []string
}

AuthResult contains the results of one token acquisition operation in PublicClientApplication or ConfidentialClientApplication. For details see https://aka.ms/msal-net-authenticationresult

func AuthResultFromStorage

func AuthResultFromStorage(storageTokenResponse storage.TokenResponse) (AuthResult, error)

AuthResultFromStorage creates an AuthResult from a storage token response (which is generated from the cache).

func NewAuthResult

func NewAuthResult(tokenResponse accesstokens.TokenResponse, account shared.Account) (AuthResult, error)

NewAuthResult creates an AuthResult.

type Client

type Client struct {
	Token *oauth.Client

	AuthParams authority.AuthParams // DO NOT EVER MAKE THIS A POINTER! See "Note" in New().
	// contains filtered or unexported fields
}

Client is a base client that provides access to common methods and primatives that can be used by multiple clients.

func New

func New(clientID string, authorityURI string, token *oauth.Client, options ...Option) (Client, error)

New is the constructor for Base.

func (Client) Account

func (b Client) Account(homeAccountID string) shared.Account

func (Client) AcquireTokenByAuthCode

func (b Client) AcquireTokenByAuthCode(ctx context.Context, authCodeParams AcquireTokenAuthCodeParameters) (AuthResult, error)

func (Client) AcquireTokenOnBehalfOf

func (b Client) AcquireTokenOnBehalfOf(ctx context.Context, onBehalfOfParams AcquireTokenOnBehalfOfParameters) (AuthResult, error)

AcquireTokenOnBehalfOf acquires a security token for an app using middle tier apps access token.

func (Client) AcquireTokenSilent

func (b Client) AcquireTokenSilent(ctx context.Context, silent AcquireTokenSilentParameters) (AuthResult, error)

func (*Client) AcquireTokenSilentNoCach

func (b *Client) AcquireTokenSilentNoCach(ctx context.Context, silent AcquireTokenSilentParameters, r Parameters) (AuthResult, error)

func (Client) AllAccounts

func (b Client) AllAccounts() []shared.Account

func (Client) AuthCodeURL

func (b Client) AuthCodeURL(ctx context.Context, clientID, redirectURI string, scopes []string, authParams authority.AuthParams) (string, error)

AuthCodeURL creates a URL used to acquire an authorization code.

func (Client) AuthResultFromToken

func (b Client) AuthResultFromToken(ctx context.Context, authParams authority.AuthParams, token accesstokens.TokenResponse, cacheWrite bool) (AuthResult, error)

func (Client) RemoveAccount

func (b Client) RemoveAccount(account shared.Account)

RemoveAccount removes all the ATs, RTs and IDTs from the cache associated with this account.

type Option

type Option func(c *Client)

Option is an optional argument to the New constructor.

func WithCacheAccessor

func WithCacheAccessor(ca cache.ExportReplace) Option

WithCacheAccessor allows you to set some type of cache for storing authentication tokens.

func WithRegionDetection

func WithRegionDetection(region string) Option

func WithX5C

func WithX5C(sendX5C bool) Option

WithX5C specifies if x5c claim(public key of the certificate) should be sent to STS to enable Subject Name Issuer Authentication.

type Parameters

type Parameters struct {
	HomeAccountID    string
	Env              string
	ClientID         string
	Username         string
	LocalAccountID   string
	Authority        string
	AuthorityType    string
	Realm            string
	PreferedUsername string

	CachedAt          time.Time
	ExpiresOn         time.Time
	ExtendedExpiresOn time.Time

	IdToken      string
	RefreshToken string
	AccessToken  string

	Scopes []string
}

Directories

Path Synopsis
internal
storage
Package storage holds all cached token information for MSAL.
Package storage holds all cached token information for MSAL.

Jump to

Keyboard shortcuts

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