Skip to content

Commit

Permalink
Support authnscheme in AcquireByUsernamePassword
Browse files Browse the repository at this point in the history
  • Loading branch information
rharpavat authored and bgavrilMS committed Feb 16, 2024
1 parent 46f1635 commit f28e36f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/public/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,13 @@ func WithClaims(claims string) interface {
func WithAuthenticationScheme(authnScheme AuthenticationScheme) interface {
AcquireSilentOption
AcquireInteractiveOption
AcquireByUsernamePasswordOption
options.CallOption
} {
return struct {
AcquireSilentOption
AcquireInteractiveOption
AcquireByUsernamePasswordOption
options.CallOption
}{
CallOption: options.NewCallOption(
Expand All @@ -231,6 +233,8 @@ func WithAuthenticationScheme(authnScheme AuthenticationScheme) interface {
t.authnScheme = authnScheme
case *interactiveAuthOptions:
t.authnScheme = authnScheme
case *acquireTokenByUsernamePasswordOptions:
t.authnScheme = authnScheme
default:
return fmt.Errorf("unexpected options type %T", a)
}
Expand Down Expand Up @@ -349,6 +353,7 @@ func (pca Client) AcquireTokenSilent(ctx context.Context, scopes []string, opts
// acquireTokenByUsernamePasswordOptions contains optional configuration for AcquireTokenByUsernamePassword
type acquireTokenByUsernamePasswordOptions struct {
claims, tenantID string
authnScheme AuthenticationScheme
}

// AcquireByUsernamePasswordOption is implemented by options for AcquireTokenByUsernamePassword
Expand All @@ -374,6 +379,9 @@ func (pca Client) AcquireTokenByUsernamePassword(ctx context.Context, scopes []s
authParams.Claims = o.claims
authParams.Username = username
authParams.Password = password
if o.authnScheme != nil {
authParams.AuthnScheme = o.authnScheme
}

token, err := pca.base.Token.UsernamePassword(ctx, authParams)
if err != nil {
Expand Down

0 comments on commit f28e36f

Please sign in to comment.