Skip to content

Commit a6ff933

Browse files
authored
Merge pull request #149 from wregis/custom-client-password-verifier
Allows client to use custom password verification
2 parents a40c7f0 + dbed049 commit a6ff933

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

manage/manager.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,15 @@ func (m *Manager) GenerateAccessToken(ctx context.Context, gt oauth2.GrantType,
256256
cli, err := m.GetClient(ctx, tgr.ClientID)
257257
if err != nil {
258258
return nil, err
259+
}
260+
if cliPass, ok := cli.(oauth2.ClientPasswordVerifier); ok {
261+
if !cliPass.VerifyPassword(tgr.ClientSecret) {
262+
return nil, errors.ErrInvalidClient
263+
}
259264
} else if tgr.ClientSecret != cli.GetSecret() {
260265
return nil, errors.ErrInvalidClient
261-
} else if tgr.RedirectURI != "" {
266+
}
267+
if tgr.RedirectURI != "" {
262268
if err := m.validateURI(cli.GetDomain(), tgr.RedirectURI); err != nil {
263269
return nil, err
264270
}

model.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ type (
1313
GetUserID() string
1414
}
1515

16+
// ClientPasswordVerifier the password handler interface
17+
ClientPasswordVerifier interface {
18+
VerifyPassword(string) bool
19+
}
20+
1621
// TokenInfo the token information model interface
1722
TokenInfo interface {
1823
New() TokenInfo

0 commit comments

Comments
 (0)