Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy: improve debugability of JWT authenticator #156

Merged
merged 2 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/serve_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"net/http"

"github.com/julienschmidt/httprouter"
"github.com/meatballhat/negroni-logrus"
negronilogrus "github.com/meatballhat/negroni-logrus"
"github.com/rs/cors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"net/http"
"net/http/httputil"

"github.com/meatballhat/negroni-logrus"
negronilogrus "github.com/meatballhat/negroni-logrus"
"github.com/rs/cors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
27 changes: 14 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@ require (
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-errors/errors v1.0.1
github.com/go-sql-driver/mysql v1.4.0
github.com/golang/mock v1.1.1
github.com/go-sql-driver/mysql v1.4.1
github.com/golang/mock v1.2.0
github.com/gorilla/sessions v1.1.3 // indirect
github.com/jmoiron/sqlx v1.2.0
github.com/julienschmidt/httprouter v1.2.0
github.com/lib/pq v1.0.0
github.com/meatballhat/negroni-logrus v0.0.0-20170801195057-31067281800f
github.com/ory/dockertest v3.3.2+incompatible
github.com/ory/fosite v0.28.0
github.com/ory/dockertest v3.3.4+incompatible
github.com/ory/fosite v0.29.0
github.com/ory/go-convenience v0.1.0
github.com/ory/graceful v0.1.0
github.com/ory/herodot v0.5.0
github.com/ory/herodot v0.6.0
github.com/ory/hydra v0.0.0-20181208123928-e4bc6c269c6f
github.com/ory/keto v0.0.0-20181213093025-a8d7f9f546ae
github.com/ory/ladon v1.0.0
github.com/ory/x v0.0.34
github.com/ory/x v0.0.37
github.com/pborman/uuid v1.2.0
github.com/pkg/errors v0.8.0
github.com/pkg/errors v0.8.1
github.com/rs/cors v1.6.0
github.com/rubenv/sql-migrate v0.0.0-20181106121204-ba2c6a7295c5
github.com/sirupsen/logrus v1.1.1
github.com/rubenv/sql-migrate v0.0.0-20190212093014-1007f53448d7
github.com/sirupsen/logrus v1.3.0
github.com/spf13/cobra v0.0.3
github.com/spf13/viper v1.2.1
github.com/stretchr/testify v1.2.2
github.com/spf13/viper v1.3.1
github.com/stretchr/testify v1.3.0
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce
github.com/urfave/negroni v1.0.0
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4
golang.org/x/oauth2 v0.0.0-20190212230446-3e8b2be13635
gopkg.in/resty.v1 v1.10.3
gopkg.in/square/go-jose.v2 v2.1.9
gopkg.in/square/go-jose.v2 v2.2.2
)
494 changes: 486 additions & 8 deletions go.sum

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion proxy/authenticator_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func (a *AuthenticatorJWT) GetID() string {
return "jwt"
}

type tracer interface {
StackTrace() errors.StackTrace
}

func (a *AuthenticatorJWT) Authenticate(r *http.Request, config json.RawMessage, rl *rule.Rule) (*AuthenticationSession, error) {
var cf AuthenticatorOAuth2JWTConfiguration
token := helper.BearerTokenFromRequest(r)
Expand Down Expand Up @@ -105,7 +109,11 @@ func (a *AuthenticatorJWT) Authenticate(r *http.Request, config json.RawMessage,
})

if err != nil {
return nil, errors.WithStack(err)
if _, ok := err.(tracer); ok {
return nil, err
} else {
return nil, errors.WithStack(err)
}
} else if !parsedToken.Valid {
return nil, errors.WithStack(fosite.ErrInactiveToken)
}
Expand Down
2 changes: 1 addition & 1 deletion rule/manager_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"github.com/pkg/errors"
"github.com/rubenv/sql-migrate"
migrate "github.com/rubenv/sql-migrate"

"github.com/ory/oathkeeper/helper"
)
Expand Down
2 changes: 1 addition & 1 deletion rule/manager_sql_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strings"

"github.com/pkg/errors"
"github.com/rubenv/sql-migrate"
migrate "github.com/rubenv/sql-migrate"
)

type sqlRule struct {
Expand Down