Skip to content

Commit

Permalink
Merge pull request #200 from stlaz/client_secrets_comparison
Browse files Browse the repository at this point in the history
Fix dependencies, add the organizational build machinery and use constant time comparisons for client secrets
  • Loading branch information
openshift-merge-robot authored Jan 13, 2021
2 parents a6e9dfb + 0a99052 commit cd6d75b
Show file tree
Hide file tree
Showing 232 changed files with 36,572 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2019-05-13
==========
* NON-BREAKING CHANGES
- Updated imports in examples to use github.com/openshift/osin instead of github.com/RangelReale/osin

2014-06-25
==========
* BREAKING CHANGES:
Expand Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
GO_BUILD_PACKAGES := .

include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
golang.mk \
targets/openshift/deps.mk \
)

build-examples:
@ for d in `find ./example -maxdepth 1 -mindepth 1 -type d`; do \
echo "building $$d" ; \
go build -race "$$d" ; \
done

clean:
@ for d in `find ./example -maxdepth 1 -mindepth 1 -type d -exec basename {} \; `; do \
echo "removing $$d" ; \
rm -f "$$d" ; \
done
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OSIN
====

[![GoDoc](https://godoc.org/github.com/RangelReale/osin?status.svg)](https://godoc.org/github.com/RangelReale/osin)
[![GoDoc](https://godoc.org/github.com/openshift/osin?status.svg)](https://godoc.org/github.com/openshift/osin)


Golang OAuth2 server library
Expand All @@ -21,8 +21,8 @@ The library implements the majority of the specification, like authorization and

````go
import (
"github.com/RangelReale/osin"
ex "github.com/RangelReale/osin/example"
"github.com/openshift/osin"
ex "github.com/openshift/osin/example"
)

// ex.NewTestStorage implements the "osin.Storage" interface
Expand Down Expand Up @@ -90,6 +90,10 @@ Rangel Reale
[email protected]

### Changes
2019-05-13
==========
* NON-BREAKING CHANGES
- Updated imports in examples to use github.com/openshift/osin instead of github.com/RangelReale/osin

2014-06-25
==========
Expand Down
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package osin

import "crypto/subtle"

// Client information
type Client interface {
// Client id
Expand Down Expand Up @@ -49,7 +51,7 @@ func (d *DefaultClient) GetUserData() interface{} {

// Implement the ClientSecretMatcher interface
func (d *DefaultClient) ClientSecretMatches(secret string) bool {
return d.Secret == secret
return subtle.ConstantTimeCompare([]byte(d.Secret), []byte(secret)) == 1
}

func (d *DefaultClient) CopyFrom(client Client) {
Expand Down
7 changes: 7 additions & 0 deletions dependencymagnet/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build tools

// go mod won't pull in code that isn't depended upon, but we have some code we don't depend on from code that must be included
// for our build to work.
package dependencymagnet

import _ "github.com/openshift/build-machinery-go"
4 changes: 2 additions & 2 deletions example/complete/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package main

import (
"fmt"
"github.com/RangelReale/osin"
"github.com/RangelReale/osin/example"
"github.com/openshift/osin"
"github.com/openshift/osin/example"
"net/http"
"net/url"
)
Expand Down
4 changes: 2 additions & 2 deletions example/goauth2client/goauth2client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"net/http"

"github.com/RangelReale/osin"
"github.com/RangelReale/osin/example"
"github.com/openshift/osin"
"github.com/openshift/osin/example"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"net/http"

"github.com/RangelReale/osin"
"github.com/openshift/osin"
)

func HandleLoginPage(ar *osin.AuthorizeRequest, w http.ResponseWriter, r *http.Request) bool {
Expand Down
4 changes: 2 additions & 2 deletions example/jwttoken/jwttoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"net/http"
"net/url"

"github.com/RangelReale/osin"
"github.com/RangelReale/osin/example"
"github.com/openshift/osin"
"github.com/openshift/osin/example"
jwt "github.com/dgrijalva/jwt-go"
)

Expand Down
4 changes: 2 additions & 2 deletions example/openidconnect/openidconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"strings"
"time"

"github.com/RangelReale/osin"
"github.com/RangelReale/osin/example"
"github.com/openshift/osin"
"github.com/openshift/osin/example"

"gopkg.in/square/go-jose.v1"
)
Expand Down
8 changes: 4 additions & 4 deletions example/osincliclient/osincliclient.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package main

// Use github.com/RangelReale/osincli client to test
// Use github.com/openshift/osincli client to test
// Open url in browser:
// http://localhost:14001

import (
"fmt"
"github.com/RangelReale/osin"
"github.com/RangelReale/osin/example"
"github.com/RangelReale/osincli"
"github.com/openshift/osin"
"github.com/openshift/osin/example"
"github.com/openshift/osincli"
"net/http"
)

Expand Down
4 changes: 2 additions & 2 deletions example/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package main

import (
"fmt"
"github.com/RangelReale/osin"
"github.com/RangelReale/osin/example"
"github.com/openshift/osin"
"github.com/openshift/osin/example"
"net/http"
"net/url"
)
Expand Down
2 changes: 1 addition & 1 deletion example/teststorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package example

import (
"fmt"
"github.com/RangelReale/osin"
"github.com/openshift/osin"
)

type TestStorage struct {
Expand Down
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module github.com/openshift/osin

go 1.15

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/openshift/build-machinery-go v0.0.0-20200917070002-f171684f77ab
github.com/openshift/osincli v0.0.0-20160924135400-fababb0555f2
github.com/pborman/uuid v1.2.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
gopkg.in/square/go-jose.v1 v1.1.2
)
25 changes: 25 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/openshift/build-machinery-go v0.0.0-20200917070002-f171684f77ab h1:lBrojddP6C9C2p67EMs2vcdpC8eF+H0DDom+fgI2IF0=
github.com/openshift/build-machinery-go v0.0.0-20200917070002-f171684f77ab/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/osincli v0.0.0-20160924135400-fababb0555f2 h1:9oADVMmPa4G60MQtoSjD26aD/vZreqbIAfiUiO220eY=
github.com/openshift/osincli v0.0.0-20160924135400-fababb0555f2/go.mod h1:Riv9DbfKiX3y9ebcS4PHU4zLhVXu971+4jCVwKIue5M=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/square/go-jose.v1 v1.1.2 h1:/5jmADZB+RiKtZGr4HxsEFOEfbfsjTKsVnqpThUpE30=
gopkg.in/square/go-jose.v1 v1.1.2/go.mod h1:QpYS+a4WhS+DTlyQIi6Ka7MS3SuR9a055rgXNEe6EiA=
3 changes: 2 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package osin

import (
"crypto/subtle"
"encoding/base64"
"errors"
"net/http"
Expand Down Expand Up @@ -28,7 +29,7 @@ func CheckClientSecret(client Client, secret string) bool {
return client.ClientSecretMatches(secret)
default:
// Fallback to the less secure method of extracting the plain text secret from the client for comparison
return client.GetSecret() == secret
return subtle.ConstantTimeCompare([]byte(client.GetSecret()), []byte(secret)) == 1
}
}

Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/dgrijalva/jwt-go/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/dgrijalva/jwt-go/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/github.com/dgrijalva/jwt-go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cd6d75b

Please sign in to comment.