Skip to content

Commit

Permalink
Merge pull request #1861 from concourse/pr/bcrypt-for-client-secret-sync
Browse files Browse the repository at this point in the history
Use constant time comparison for client secret verification
  • Loading branch information
sagikazarmark committed May 17, 2021
2 parents 283dd89 + fe8085b commit 18d1f70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/handlers.go
Expand Up @@ -2,6 +2,7 @@ package server

import (
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -678,7 +679,8 @@ func (s *Server) withClientFromStorage(w http.ResponseWriter, r *http.Request, h
}
return
}
if client.Secret != clientSecret {

if subtle.ConstantTimeCompare([]byte(client.Secret), []byte(clientSecret)) != 1 {
if clientSecret == "" {
s.logger.Infof("missing client_secret on token request for client: %s", client.ID)
} else {
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Expand Up @@ -204,6 +204,7 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
if c.Storage == nil {
return nil, errors.New("server: storage cannot be nil")
}

if len(c.SupportedResponseTypes) == 0 {
c.SupportedResponseTypes = []string{responseTypeCode}
}
Expand Down

0 comments on commit 18d1f70

Please sign in to comment.