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

Use alg() to compare two method instead compare directly #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions session_storer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type SessionStorer struct {
// Get get claims from request
func (sessionStorer *SessionStorer) Get(req *http.Request) (*claims.Claims, error) {
tokenString := req.Header.Get("Authorization")

// Get Token from Cookie
if tokenString == "" {
tokenString = sessionStorer.SessionManager.Get(req, sessionStorer.SessionName)
Expand Down Expand Up @@ -83,7 +82,7 @@ func (sessionStorer *SessionStorer) SignedToken(claims *claims.Claims) string {
// ValidateClaims validate auth token
func (sessionStorer *SessionStorer) ValidateClaims(tokenString string) (*claims.Claims, error) {
token, err := jwt.ParseWithClaims(tokenString, &claims.Claims{}, func(token *jwt.Token) (interface{}, error) {
if token.Method != sessionStorer.SigningMethod {
if token.Method.Alg() != sessionStorer.SigningMethod.Alg() {
return nil, fmt.Errorf("unexpected signing method")
}
return []byte(sessionStorer.SignedString), nil
Expand Down