Skip to content

Commit

Permalink
vendor: update fosite 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) committed Aug 23, 2016
1 parent 8911e0f commit a487a62
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 41 deletions.
4 changes: 2 additions & 2 deletions client/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func BenchmarkRethinkAuthenticate(b *testing.B) {
}

func TestColdStartRethinkManager(t *testing.T) {
assert.Nil(t, rethinkManager.CreateClient(&Client{ID: "foo" }))
assert.Nil(t, rethinkManager.CreateClient(&Client{ID: "bar" }))
assert.Nil(t, rethinkManager.CreateClient(&Client{ID: "foo"}))
assert.Nil(t, rethinkManager.CreateClient(&Client{ID: "bar"}))

time.Sleep(time.Second / 2)
rethinkManager.Clients = make(map[string]Client)
Expand Down
11 changes: 5 additions & 6 deletions cmd/server/handler_oauth2_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"github.com/ory-am/fosite/compose"
"github.com/ory-am/hydra/client"
"github.com/ory-am/hydra/config"
"github.com/ory-am/hydra/herodot"
"github.com/ory-am/hydra/internal"
"github.com/ory-am/hydra/jwk"
"github.com/ory-am/hydra/oauth2"
"github.com/ory-am/hydra/pkg"
"golang.org/x/net/context"
r "gopkg.in/dancannon/gorethink.v2"
"github.com/ory-am/hydra/herodot"
)

func injectFositeStore(c *config.Config, clients client.Manager) {
Expand Down Expand Up @@ -135,13 +135,12 @@ func newOAuth2Handler(c *config.Config, router *httprouter.Router, km jwk.Manage
},
ConsentURL: *consentURL,
Introspector: &oauth2.LocalIntrospector{
OAuth2: o,
OAuth2: o,
AccessTokenLifespan: c.GetAccessTokenLifespan(),
Issuer : c.Issuer,

Issuer: c.Issuer,
},
Firewall: ctx.Warden,
H: &herodot.JSON{},
Firewall: ctx.Warden,
H: &herodot.JSON{},
}

handler.SetRoutes(router)
Expand Down
2 changes: 1 addition & 1 deletion cmd/token_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var tokenUserCmd = &cobra.Command{
AuthURL: pkg.JoinURLStrings(c.ClusterURL, "/oauth2/auth"),
},
RedirectURL: "http://localhost:4445/callback",
Scopes: scopes,
Scopes: scopes,
}

state, err := sequence.RuneSequence(24, []rune("abcdefghijklmnopqrstuvwxyz"))
Expand Down
2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import:
- package: github.com/dgrijalva/jwt-go
version: ~3.0.0
- package: github.com/ory-am/fosite
version: 76ef7ea8f51735d63476cd91e1f9a9f367d544cb #should be changed to a sem-ver
version: ~0.3.0
subpackages:
- compose
- fosite-example/pkg
Expand Down
6 changes: 3 additions & 3 deletions internal/fosite_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/ory-am/hydra/client"
"github.com/ory-am/hydra/pkg"
"github.com/pborman/uuid"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
r "gopkg.in/dancannon/gorethink.v2"
"github.com/stretchr/testify/assert"
)

var rethinkManager *FositeRehinkDBStore
Expand Down Expand Up @@ -111,8 +111,8 @@ func TestColdStartRethinkManager(t *testing.T) {
err := m.CreateAuthorizeCodeSession(ctx, id, &defaultRequest)
pkg.AssertError(t, false, err)
err = m.CreateAccessTokenSession(ctx, "12345", &fosite.Request{
RequestedAt: time.Now().Round(time.Second),
Client: &client.Client{ID: "baz"},
RequestedAt: time.Now().Round(time.Second),
Client: &client.Client{ID: "baz"},
})
pkg.AssertError(t, false, err)

Expand Down
12 changes: 6 additions & 6 deletions oauth2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/go-errors/errors"
"github.com/julienschmidt/httprouter"
"github.com/ory-am/fosite"
"github.com/ory-am/hydra/firewall"
"github.com/ory-am/hydra/herodot"
"github.com/ory-am/hydra/pkg"
"github.com/ory-am/hydra/firewall"
)

const (
Expand All @@ -24,15 +24,15 @@ const (
)

type Handler struct {
OAuth2 fosite.OAuth2Provider
Consent ConsentStrategy
OAuth2 fosite.OAuth2Provider
Consent ConsentStrategy

Introspector Introspector
Firewall firewall.Firewall
H herodot.Herodot
H herodot.Herodot

ForcedHTTP bool
ConsentURL url.URL
ForcedHTTP bool
ConsentURL url.URL
}

func (this *Handler) SetRoutes(r *httprouter.Router) {
Expand Down
16 changes: 8 additions & 8 deletions oauth2/introspector_http.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package oauth2

import (
"net/url"
"bytes"
"io/ioutil"
"net/http"
"golang.org/x/net/context"
"strconv"
"encoding/json"
"github.com/go-errors/errors"
"github.com/ory-am/fosite"
"golang.org/x/oauth2/clientcredentials"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"github.com/go-errors/errors"
"golang.org/x/oauth2/clientcredentials"
"io/ioutil"
"net/http"
"net/url"
"strconv"
)

type HTTPIntrospector struct {
Expand Down Expand Up @@ -61,4 +61,4 @@ func (this *HTTPIntrospector) IntrospectToken(ctx context.Context, token string)
}

return resp, nil
}
}
12 changes: 6 additions & 6 deletions oauth2/introspector_local.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package oauth2

import (
"github.com/Sirupsen/logrus"
"github.com/ory-am/fosite"
"time"
"strings"
"net/http"
"golang.org/x/net/context"
"github.com/Sirupsen/logrus"
"net/http"
"strings"
"time"
)

type LocalIntrospector struct {
Expand Down Expand Up @@ -40,6 +40,6 @@ func (w *LocalIntrospector) IntrospectToken(ctx context.Context, token string) (
IssuedAt: auth.GetRequestedAt().Unix(),
NotBefore: auth.GetRequestedAt().Unix(),
ExpiresAt: session.AccessTokenExpiresAt(auth.GetRequestedAt().Add(w.AccessTokenLifespan)).Unix(),
Extra: session.Extra,
Extra: session.Extra,
}, nil
}
}
6 changes: 3 additions & 3 deletions oauth2/introspector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ func init() {
ts = httptest.NewServer(r)

ar := fosite.NewAccessRequest(oauth2.NewSession("alice"))
ar.GrantedScopes = fosite.Arguments{0: "core"}
ar.GrantedScopes = fosite.Arguments{"core"}
ar.RequestedAt = now
ar.Client = &fosite.DefaultClient{ID: "siri"}
ar.Session.(*oauth2.Session).Extra = map[string]interface{}{"foo": "bar"}
fositeStore.CreateAccessTokenSession(nil, tokens[0][0], ar)

ar2 := fosite.NewAccessRequest(oauth2.NewSession("siri"))
ar2.GrantedScopes = fosite.Arguments{0: "core"}
ar2.GrantedScopes = fosite.Arguments{"core"}
ar2.RequestedAt = now
ar2.Session.(*oauth2.Session).Extra = map[string]interface{}{"foo": "bar"}
ar2.Client = &fosite.DefaultClient{ID: "siri"}
fositeStore.CreateAccessTokenSession(nil, tokens[1][0], ar2)

ar3 := fosite.NewAccessRequest(oauth2.NewSession("siri"))
ar3.GrantedScopes = fosite.Arguments{0: "core"}
ar3.GrantedScopes = fosite.Arguments{"core"}
ar3.RequestedAt = now
ar2.Session.(*oauth2.Session).Extra = map[string]interface{}{"foo": "bar"}
ar3.Client = &fosite.DefaultClient{ID: "doesnt-exist"}
Expand Down
2 changes: 1 addition & 1 deletion sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/ory-am/hydra/client"
"github.com/ory-am/hydra/connection"
"github.com/ory-am/hydra/jwk"
hoauth2 "github.com/ory-am/hydra/oauth2"
"github.com/ory-am/hydra/pkg"
"github.com/ory-am/hydra/policy"
hoauth2 "github.com/ory-am/hydra/oauth2"
"github.com/ory-am/hydra/warden"
"golang.org/x/net/context"
"golang.org/x/oauth2"
Expand Down
1 change: 0 additions & 1 deletion sdk/client_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func ClusterURL(urlStr string) option {
}
}


// ClientID sets the OAuth2 Client ID.
//
// var hydra, err = sdk.Connect(
Expand Down
2 changes: 1 addition & 1 deletion sdk/client_opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"
"testing"

"gopkg.in/yaml.v2"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
)

func TestClusterURLOption(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions warden/warden_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
)

type LocalWarden struct {
Warden ladon.Warden
OAuth2 fosite.OAuth2Provider
Warden ladon.Warden
OAuth2 fosite.OAuth2Provider

AccessTokenLifespan time.Duration
Issuer string
Expand Down

0 comments on commit a487a62

Please sign in to comment.