package base
import "github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/base"
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
- Variables
- type AcquireTokenAuthCodeParameters
- type AcquireTokenOnBehalfOfParameters
- type AcquireTokenSilentParameters
- type AuthResult
- func AuthResultFromStorage(storageTokenResponse storage.TokenResponse) (AuthResult, error)
- func NewAuthResult(tokenResponse accesstokens.TokenResponse, account shared.Account) (AuthResult, error)
- type AuthResultMetadata
- type Client
- func New(clientID string, authorityURI string, token *oauth.Client, options ...Option) (Client, error)
- func (b Client) Account(ctx context.Context, homeAccountID string) (shared.Account, error)
- func (b Client) AcquireTokenByAuthCode(ctx context.Context, authCodeParams AcquireTokenAuthCodeParameters) (AuthResult, error)
- func (b Client) AcquireTokenOnBehalfOf(ctx context.Context, onBehalfOfParams AcquireTokenOnBehalfOfParameters) (AuthResult, error)
- func (b Client) AcquireTokenSilent(ctx context.Context, silent AcquireTokenSilentParameters) (AuthResult, error)
- func (b Client) AllAccounts(ctx context.Context) ([]shared.Account, error)
- func (b Client) AuthCodeURL(ctx context.Context, clientID, redirectURI string, scopes []string, authParams authority.AuthParams) (string, error)
- func (b Client) AuthResultFromToken(ctx context.Context, authParams authority.AuthParams, token accesstokens.TokenResponse) (AuthResult, error)
- func (b Client) RemoveAccount(ctx context.Context, account shared.Account) error
- type Option
- func WithCacheAccessor(ca cache.ExportReplace) Option
- func WithClientCapabilities(capabilities []string) Option
- func WithInstanceDiscovery(instanceDiscoveryEnabled bool) Option
- func WithKnownAuthorityHosts(hosts []string) Option
- func WithRegionDetection(region string) Option
- func WithX5C(sendX5C bool) Option
- type TokenSource
Constants ¶
const ( // AuthorityPublicCloud is the default AAD authority host AuthorityPublicCloud = "https://login.microsoftonline.com/common" )
Variables ¶
This function wraps time.Now() and is used for refreshing the application was created to test the function against refreshin
Types ¶
type AcquireTokenAuthCodeParameters ¶
type AcquireTokenAuthCodeParameters struct { Scopes []string Code string Challenge string Claims string RedirectURI string AppType accesstokens.AppType Credential *accesstokens.Credential TenantID string }
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 Claims string Credential *accesstokens.Credential TenantID string UserAssertion string }
type AcquireTokenSilentParameters ¶
type AcquireTokenSilentParameters struct { Scopes []string Account shared.Account RequestType accesstokens.AppType Credential *accesstokens.Credential IsAppCache bool TenantID string UserAssertion string AuthorizationType authority.AuthorizeType Claims string AuthnScheme authority.AuthenticationScheme }
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 Metadata AuthResultMetadata }
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 AuthResultMetadata ¶
type AuthResultMetadata struct { RefreshOn time.Time TokenSource TokenSource }
AuthResultMetadata which contains meta data for the 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 (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) AllAccounts ¶
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) (AuthResult, error)
func (Client) RemoveAccount ¶
RemoveAccount removes all the ATs, RTs and IDTs from the cache associated with this account.
type Option ¶
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 WithClientCapabilities ¶
WithClientCapabilities allows configuring one or more client capabilities such as "CP1"
func WithInstanceDiscovery ¶
func WithKnownAuthorityHosts ¶
WithKnownAuthorityHosts specifies hosts Client shouldn't validate or request metadata for because they're known to the user
func WithRegionDetection ¶
func WithX5C ¶
WithX5C specifies if x5c claim(public key of the certificate) should be sent to STS to enable Subject Name Issuer Authentication.
type TokenSource ¶
type TokenSource int
const ( TokenSourceIdentityProvider TokenSource = 0 TokenSourceCache TokenSource = 1 )
These are all the types of token flows.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
apps/internal/base/storage | Package storage holds all cached token information for MSAL. |
- Version
- v1.4.2 (latest)
- Published
- Mar 26, 2025
- Platform
- linux/amd64
- Imports
- 15 packages
- Last checked
- 2 days ago –
Tools for package owners.