Skip to content

Commit

Permalink
lint: gofmt -w -s .
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) authored and arekkas committed Dec 20, 2016
1 parent 3f347e3 commit 95caa96
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 40 deletions.
19 changes: 10 additions & 9 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
ErrTokenExpired = errors.New("Token expired")
ErrScopeNotGranted = errors.New("The token was not granted the requested scope")
ErrTokenClaim = errors.New("The token failed validation due to a claim mismatch")
ErrInactiveToken = errors.New("Token is inactive because it is malformed, expired or otherwise invalid")
ErrInactiveToken = errors.New("Token is inactive because it is malformed, expired or otherwise invalid")
)

const (
Expand Down Expand Up @@ -67,17 +67,18 @@ type RFC6749Error struct {

func ErrorToRFC6749Error(err error) *RFC6749Error {
switch errors.Cause(err) {
case ErrInactiveToken: {
case ErrInactiveToken:
{
return &RFC6749Error{
Name: errTokenInactive,
Description: ErrInactiveToken.Error(),
Debug: err.Error(),
Hint: "Token validation failed.",
StatusCode: http.StatusUnauthorized,
{
return &RFC6749Error{
Name: errTokenInactive,
Description: ErrInactiveToken.Error(),
Debug: err.Error(),
Hint: "Token validation failed.",
StatusCode: http.StatusUnauthorized,
}
}
}
}
case ErrTokenClaim:
{
return &RFC6749Error{
Expand Down
4 changes: 2 additions & 2 deletions handler/oauth2/strategy_jwt_session.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package oauth2

import (
"bytes"
"encoding/gob"
"github.com/ory-am/fosite"
"github.com/ory-am/fosite/token/jwt"
"time"
"bytes"
"encoding/gob"
)

type JWTSessionContainer interface {
Expand Down
6 changes: 3 additions & 3 deletions handler/openid/flow_hybrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type OpenIDConnectHybridHandler struct {
IDTokenHandleHelper *IDTokenHandleHelper
ScopeStrategy fosite.ScopeStrategy

Enigma *jwt.RS256JWTStrategy
Enigma *jwt.RS256JWTStrategy
}

func (c *OpenIDConnectHybridHandler) HandleAuthorizeEndpointRequest(ctx context.Context, req *http.Request, ar fosite.AuthorizeRequester, resp fosite.AuthorizeResponder) error {
Expand Down Expand Up @@ -71,7 +71,7 @@ func (c *OpenIDConnectHybridHandler) HandleAuthorizeEndpointRequest(ctx context.
if err != nil {
return err
}
claims.CodeHash = []byte(base64.URLEncoding.EncodeToString([]byte(hash[:c.Enigma.GetSigningMethodLength() / 2])))
claims.CodeHash = []byte(base64.URLEncoding.EncodeToString([]byte(hash[:c.Enigma.GetSigningMethodLength()/2])))
}

if ar.GetResponseTypes().Has("token") {
Expand All @@ -86,7 +86,7 @@ func (c *OpenIDConnectHybridHandler) HandleAuthorizeEndpointRequest(ctx context.
if err != nil {
return err
}
claims.AccessTokenHash = []byte(base64.URLEncoding.EncodeToString([]byte(hash[:c.Enigma.GetSigningMethodLength() / 2])))
claims.AccessTokenHash = []byte(base64.URLEncoding.EncodeToString([]byte(hash[:c.Enigma.GetSigningMethodLength()/2])))
}

if resp.GetFragment().Get("state") == "" {
Expand Down
6 changes: 3 additions & 3 deletions handler/openid/flow_implicit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
type OpenIDConnectImplicitHandler struct {
AuthorizeImplicitGrantTypeHandler *oauth2.AuthorizeImplicitGrantTypeHandler
*IDTokenHandleHelper
ScopeStrategy fosite.ScopeStrategy
ScopeStrategy fosite.ScopeStrategy

RS256JWTStrategy *jwt.RS256JWTStrategy
RS256JWTStrategy *jwt.RS256JWTStrategy
}

func (c *OpenIDConnectImplicitHandler) HandleAuthorizeEndpointRequest(ctx context.Context, req *http.Request, ar fosite.AuthorizeRequester, resp fosite.AuthorizeResponder) error {
Expand Down Expand Up @@ -63,7 +63,7 @@ func (c *OpenIDConnectImplicitHandler) HandleAuthorizeEndpointRequest(ctx contex
return err
}

claims.AccessTokenHash = []byte(base64.URLEncoding.EncodeToString([]byte(hash[:c.RS256JWTStrategy.GetSigningMethodLength() / 2])))
claims.AccessTokenHash = []byte(base64.URLEncoding.EncodeToString([]byte(hash[:c.RS256JWTStrategy.GetSigningMethodLength()/2])))
} else {
resp.AddFragment("state", ar.GetState())
}
Expand Down
2 changes: 1 addition & 1 deletion handler/openid/flow_implicit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestImplicit_HandleAuthorizeEndpointRequest(t *testing.T) {
Claims: &jwt.IDTokenClaims{
Subject: "peter",
},
Headers: &jwt.Headers{},
Headers: &jwt.Headers{},
}
areq.Form.Add("nonce", "some-random-foo-nonce-wow")
},
Expand Down
9 changes: 4 additions & 5 deletions handler/openid/strategy_jwt.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package openid

import (
"net/http"
"encoding/gob"
"net/http"
"time"

"bytes"
"github.com/ory-am/fosite"
"github.com/ory-am/fosite/token/jwt"
"github.com/pkg/errors"
"golang.org/x/net/context"
"bytes"
)

const defaultExpiryTime = time.Hour
Expand All @@ -32,8 +32,8 @@ type DefaultSession struct {

func NewDefaultSession() *DefaultSession {
return &DefaultSession{
Claims: &jwt.IDTokenClaims{},
Headers: &jwt.Headers{},
Claims: &jwt.IDTokenClaims{},
Headers: &jwt.Headers{},
}
}

Expand All @@ -51,7 +51,6 @@ func (s *DefaultSession) Clone() fosite.Session {
return &clone
}


func (s *DefaultSession) SetExpiresAt(key fosite.TokenType, exp time.Time) {
if s.ExpiresAt == nil {
s.ExpiresAt = make(map[fosite.TokenType]time.Time)
Expand Down
8 changes: 4 additions & 4 deletions integration/introspect_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ func runIntrospectTokenTest(t *testing.T, strategy oauth2.AccessTokenStrategy) {
},
{
prepare: func(s *gorequest.SuperAgent) *gorequest.SuperAgent {
return s.Set("Authorization", "bearer " + a.AccessToken)
return s.Set("Authorization", "bearer "+a.AccessToken)
},
isActive: true,
scopes: "fosite",
},
{
prepare: func(s *gorequest.SuperAgent) *gorequest.SuperAgent {
return s.Set("Authorization", "bearer " + a.AccessToken)
return s.Set("Authorization", "bearer "+a.AccessToken)
},
isActive: true,
scopes: "",
},
{
prepare: func(s *gorequest.SuperAgent) *gorequest.SuperAgent {
return s.Set("Authorization", "bearer " + a.AccessToken)
return s.Set("Authorization", "bearer "+a.AccessToken)
},
isActive: false,
scopes: "foo",
},
{
prepare: func(s *gorequest.SuperAgent) *gorequest.SuperAgent {
return s.Set("Authorization", "bearer " + b.AccessToken)
return s.Set("Authorization", "bearer "+b.AccessToken)
},
isActive: false,
scopes: "",
Expand Down
2 changes: 1 addition & 1 deletion integration/oidc_explicit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestOpenIDConnectExplicitFlow(t *testing.T) {
Claims: &jwt.IDTokenClaims{
Subject: "peter",
},
Headers: &jwt.Headers{},
Headers: &jwt.Headers{},
},
}
f := compose.ComposeAllEnabled(new(compose.Config), fositeStore, []byte("some-secret-thats-random"), internal.MustRSAKey())
Expand Down
12 changes: 6 additions & 6 deletions integration/oidc_implicit_hybrid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestOIDCImplicitFlow(t *testing.T) {
Claims: &jwt.IDTokenClaims{
Subject: "peter",
},
Headers: &jwt.Headers{},
Headers: &jwt.Headers{},
},
}
f := compose.ComposeAllEnabled(new(compose.Config), fositeStore, []byte("some-secret-thats-random"), internal.MustRSAKey())
Expand All @@ -51,7 +51,7 @@ func TestOIDCImplicitFlow(t *testing.T) {
setup: func() {
oauthClient.Scopes = []string{"fosite"}
},
hasToken: true,
hasToken: true,
},
{

Expand All @@ -61,7 +61,7 @@ func TestOIDCImplicitFlow(t *testing.T) {
setup: func() {
oauthClient.Scopes = []string{"fosite", "openid"}
},
hasToken: true,
hasToken: true,
hasIdToken: true,
},

Expand All @@ -73,7 +73,7 @@ func TestOIDCImplicitFlow(t *testing.T) {
setup: func() {},
hasToken: true,
hasCode: true,
hasIdToken: true,
hasIdToken: true,
},
{

Expand All @@ -91,13 +91,13 @@ func TestOIDCImplicitFlow(t *testing.T) {
description: "should pass id token (id_token code)",
setup: func() {},
hasCode: true,
hasIdToken: true,
hasIdToken: true,
},
} {
c.setup()

var callbackURL *url.URL
authURL := strings.Replace(oauthClient.AuthCodeURL(state), "response_type=code", "response_type=" + c.responseType, -1) + "&nonce=" + c.nonce
authURL := strings.Replace(oauthClient.AuthCodeURL(state), "response_type=code", "response_type="+c.responseType, -1) + "&nonce=" + c.nonce
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
callbackURL = req.URL
Expand Down
8 changes: 4 additions & 4 deletions integration/revoke_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ func runRevokeTokenTest(t *testing.T, strategy oauth2.AccessTokenStrategy) {
token, err := oauthClient.Token(goauth.NoContext)
assert.Nil(t, err)

resp, _, errs := gorequest.New().Post(ts.URL + "/revoke").
resp, _, errs := gorequest.New().Post(ts.URL+"/revoke").
SetBasicAuth(oauthClient.ClientID, oauthClient.ClientSecret).
Type("form").
SendStruct(map[string]string{"token": "asdf"}).End()
assert.Len(t, errs, 0)
assert.Equal(t, 200, resp.StatusCode)

resp, _, errs = gorequest.New().Post(ts.URL + "/revoke").
resp, _, errs = gorequest.New().Post(ts.URL+"/revoke").
SetBasicAuth(oauthClient.ClientID, oauthClient.ClientSecret).
Type("form").
SendStruct(map[string]string{"token": token.AccessToken}).End()
assert.Len(t, errs, 0)
assert.Equal(t, 200, resp.StatusCode)

hres, _, errs := gorequest.New().Get(ts.URL + "/info").
Set("Authorization", "bearer " + token.AccessToken).
hres, _, errs := gorequest.New().Get(ts.URL+"/info").
Set("Authorization", "bearer "+token.AccessToken).
End()
require.Len(t, errs, 0)
assert.Equal(t, http.StatusUnauthorized, hres.StatusCode)
Expand Down
2 changes: 1 addition & 1 deletion introspection_request_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestNewIntrospectionRequest(t *testing.T) {
validator.EXPECT().IntrospectToken(nil, "some-token", gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
validator.EXPECT().IntrospectToken(nil, "introspect-token", gomock.Any(), gomock.Any(), gomock.Any()).Return(newErr)
},
isActive: false,
isActive: false,
expectErr: newErr,
},
{
Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fosite

import (
"time"
"bytes"
"encoding/gob"
"time"
)

// Session is an interface that is used to store session data between OAuth2 requests. It can be used to look up
Expand Down

0 comments on commit 95caa96

Please sign in to comment.