Skip to content

Commit

Permalink
add username auth for totp (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-lifshits authored Aug 29, 2024
1 parent 1a68123 commit 5bb4781
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions auth_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[s
}

type totpUserReq struct {
ID string `json:"id"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Passcode string `json:"passcode"`
}

Expand Down Expand Up @@ -253,12 +254,13 @@ func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[s
}
}
if opts.Passcode != "" {
if opts.UserID == "" {
return nil, ErrUserIDNotFound{}
if opts.Username == "" && opts.UserID == "" {
return nil, ErrUsernameOrUserID{}
}
req.Auth.Identity.TOTP = &totpReq{
User: totpUserReq{
ID: opts.UserID,
Name: opts.Username,
Passcode: opts.Passcode,
},
}
Expand Down

0 comments on commit 5bb4781

Please sign in to comment.