Skip to content

Commit

Permalink
all: gofmt -w -s
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) authored and arekkas committed Mar 24, 2017
1 parent e182085 commit b22d26f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 44 deletions.
2 changes: 1 addition & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestExecute(t *testing.T) {
c.args = append(c.args, []string{"--skip-tls-verify", "--config", path}...)
RootCmd.SetArgs(c.args)

t.Run(fmt.Sprintf("command=%v", c.args), func (t *testing.T) {
t.Run(fmt.Sprintf("command=%v", c.args), func(t *testing.T) {
if c.wait != nil {
go func() {
assert.Nil(t, RootCmd.Execute())
Expand Down
38 changes: 19 additions & 19 deletions compose/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
. "github.com/ory-am/hydra/oauth2"
"github.com/ory-am/hydra/pkg"
"github.com/ory-am/hydra/warden"
"github.com/ory-am/hydra/warden/group"
"github.com/ory-am/ladon"
"golang.org/x/oauth2"
"github.com/ory-am/hydra/warden/group"
)

func NewFirewall(issuer string, subject string, scopes fosite.Arguments, p ...ladon.Policy) (firewall.Firewall, *http.Client) {
Expand All @@ -33,24 +33,24 @@ func NewFirewall(issuer string, subject string, scopes fosite.Arguments, p ...la
conf := &oauth2.Config{Scopes: scopes, Endpoint: oauth2.Endpoint{}}

return &warden.LocalWarden{
Warden: ladonWarden,
OAuth2: &fosite.Fosite{
Store: fositeStore,
TokenIntrospectionHandlers: fosite.TokenIntrospectionHandlers{
&foauth2.CoreValidator{
CoreStrategy: pkg.HMACStrategy,
CoreStorage: fositeStore,
ScopeStrategy: fosite.HierarchicScopeStrategy,
Warden: ladonWarden,
OAuth2: &fosite.Fosite{
Store: fositeStore,
TokenIntrospectionHandlers: fosite.TokenIntrospectionHandlers{
&foauth2.CoreValidator{
CoreStrategy: pkg.HMACStrategy,
CoreStorage: fositeStore,
ScopeStrategy: fosite.HierarchicScopeStrategy,
},
},
ScopeStrategy: fosite.HierarchicScopeStrategy,
},
ScopeStrategy: fosite.HierarchicScopeStrategy,
},
Issuer: issuer,
AccessTokenLifespan: time.Hour,
Groups: group.NewMemoryManager(),
}, conf.Client(oauth2.NoContext, &oauth2.Token{
AccessToken: tokens[0][1],
Expiry: time.Now().Add(time.Hour),
TokenType: "bearer",
})
Issuer: issuer,
AccessTokenLifespan: time.Hour,
Groups: group.NewMemoryManager(),
}, conf.Client(oauth2.NoContext, &oauth2.Token{
AccessToken: tokens[0][1],
Expiry: time.Now().Add(time.Hour),
TokenType: "bearer",
})
}
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Config struct {
AuthCodeLifespan string `mapstructure:"AUTH_CODE_LIFESPAN" yaml:"-"`
IDTokenLifespan string `mapstructure:"ID_TOKEN_LIFESPAN" yaml:"-"`
ChallengeTokenLifespan string `mapstructure:"CHALLENGE_TOKEN_LIFESPAN" yaml:"-"`
CookieSecret string `mapstructure:"COOKIE_SECRET" yaml:"-"`
CookieSecret string `mapstructure:"COOKIE_SECRET" yaml:"-"`
ForceHTTP bool `yaml:"-"`

cluster *url.URL `yaml:"-"`
Expand Down
2 changes: 0 additions & 2 deletions herodot/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func ToError(err error) *Error {
}
}



return &Error{
OriginalError: err,
Name: "internal-error",
Expand Down
16 changes: 8 additions & 8 deletions integration/sql_schema_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package integration

import (
"testing"
"github.com/ory-am/hydra/client"
"github.com/ory-am/fosite"
"github.com/stretchr/testify/require"
"github.com/ory-am/hydra/policy"
"github.com/ory-am/hydra/client"
"github.com/ory-am/hydra/jwk"
"github.com/ory-am/hydra/oauth2"
"github.com/ory-am/ladon"
"github.com/ory-am/hydra/policy"
"github.com/ory-am/hydra/warden/group"
"github.com/ory-am/ladon"
"github.com/stretchr/testify/require"
"testing"
)

func TestSQLSchema(t *testing.T) {
Expand All @@ -20,10 +20,10 @@ func TestSQLSchema(t *testing.T) {
r.ID = "foo"
db := ConnectToMySQL()

cm := &client.SQLManager{DB: db, Hasher: &fosite.BCrypt{}}
cm := &client.SQLManager{DB: db, Hasher: &fosite.BCrypt{}}
gm := group.SQLManager{DB: db}
jm := jwk.SQLManager{DB: db, Cipher: &jwk.AEAD{Key: []byte("11111111111111111111111111111111")}}
om := oauth2.FositeSQLStore{Manager: cm, DB: db }
om := oauth2.FositeSQLStore{Manager: cm, DB: db}
pm, err := policy.NewSQLManager(db)
require.Nil(t, err)

Expand All @@ -37,7 +37,7 @@ func TestSQLSchema(t *testing.T) {
require.Nil(t, cm.CreateClient(&client.Client{ID: "foo"}))
require.Nil(t, om.CreateAccessTokenSession(nil, "asdfasdf", r))
require.Nil(t, gm.CreateGroup(&group.Group{
ID: "asdfas",
ID: "asdfas",
Members: []string{"asdf"},
}))
}
14 changes: 7 additions & 7 deletions policy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
)

const (
endpoint = "/policies"
scope = "hydra.policies"
policyResource = "rn:hydra:policies"
endpoint = "/policies"
scope = "hydra.policies"
policyResource = "rn:hydra:policies"
policiesResource = "rn:hydra:policies:%s"
)

Expand All @@ -29,9 +29,9 @@ type Handler struct {
func (h *Handler) SetRoutes(r *httprouter.Router) {
r.POST(endpoint, h.Create)
r.GET(endpoint, h.Find)
r.GET(endpoint + "/:id", h.Get)
r.PUT(endpoint + "/:id", h.Update)
r.DELETE(endpoint + "/:id", h.Delete)
r.GET(endpoint+"/:id", h.Get)
r.PUT(endpoint+"/:id", h.Update)
r.DELETE(endpoint+"/:id", h.Delete)
}

func (h *Handler) Find(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
Expand Down Expand Up @@ -84,7 +84,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request, _ httprouter.Pa
h.H.WriteError(ctx, w, r, errors.WithStack(err))
return
}
h.H.WriteCreated(ctx, w, r, "/policies/" + p.ID, &p)
h.H.WriteCreated(ctx, w, r, "/policies/"+p.ID, &p)
}

func (h *Handler) Get(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
Expand Down
4 changes: 2 additions & 2 deletions policy/manager.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package policy

import (
"github.com/ory-am/ladon"
"github.com/jmoiron/sqlx"
"github.com/ory-am/ladon"
"github.com/rubenv/sql-migrate"
)

Expand All @@ -21,4 +21,4 @@ func NewSQLManager(db *sqlx.DB) (ladon.Manager, error) {
return nil, err
}
return m, nil
}
}
8 changes: 4 additions & 4 deletions warden/warden_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/ory-am/hydra/oauth2"
"github.com/ory-am/hydra/warden/group"
"github.com/ory-am/ladon"
"golang.org/x/net/context"
"github.com/pkg/errors"
"golang.org/x/net/context"
)

type LocalWarden struct {
Expand Down Expand Up @@ -81,8 +81,8 @@ func (w *LocalWarden) TokenAllowed(ctx context.Context, token string, a *firewal
logrus.WithFields(logrus.Fields{
"subject": c.Subject,
"audience": auth.GetClient().GetID(),
"request": auth,
"result": c,
"request": auth,
"result": c,
}).Infof("Access granted")

return c, nil
Expand All @@ -94,7 +94,7 @@ func (w *LocalWarden) isAllowed(ctx context.Context, a *ladon.Request) error {
return err
}

errs := make([]error, len(groups) + 1)
errs := make([]error, len(groups)+1)
errs[0] = w.Warden.IsAllowed(&ladon.Request{
Resource: a.Resource,
Action: a.Action,
Expand Down

0 comments on commit b22d26f

Please sign in to comment.