File tree 2 files changed +5
-2
lines changed
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 1
1
package osin
2
2
3
+ import "crypto/subtle"
4
+
3
5
// Client information
4
6
type Client interface {
5
7
// Client id
@@ -49,7 +51,7 @@ func (d *DefaultClient) GetUserData() interface{} {
49
51
50
52
// Implement the ClientSecretMatcher interface
51
53
func (d * DefaultClient ) ClientSecretMatches (secret string ) bool {
52
- return d .Secret == secret
54
+ return subtle . ConstantTimeCompare ([] byte ( d .Secret ), [] byte ( secret )) == 1
53
55
}
54
56
55
57
func (d * DefaultClient ) CopyFrom (client Client ) {
Original file line number Diff line number Diff line change 1
1
package osin
2
2
3
3
import (
4
+ "crypto/subtle"
4
5
"encoding/base64"
5
6
"errors"
6
7
"net/http"
@@ -28,7 +29,7 @@ func CheckClientSecret(client Client, secret string) bool {
28
29
return client .ClientSecretMatches (secret )
29
30
default :
30
31
// Fallback to the less secure method of extracting the plain text secret from the client for comparison
31
- return client .GetSecret () == secret
32
+ return subtle . ConstantTimeCompare ([] byte ( client .GetSecret ()), [] byte ( secret )) == 1
32
33
}
33
34
}
34
35
You can’t perform that action at this time.
0 commit comments