mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-04 18:21:06 +02:00
check token expiry
This commit is contained in:
parent
d1d762aa83
commit
a40d20dcdb
@ -60,12 +60,20 @@ func (s *session) GetLogin(r *http.Request) *common.Token {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &common.Token{
|
||||
token := &common.Token{
|
||||
Kind: claims["kind"].(string),
|
||||
Login: claims["user"].(string),
|
||||
Label: claims["label"].(string),
|
||||
Issued: int64(claims["date"].(float64)),
|
||||
}
|
||||
if token.Kind != common.TokenSess {
|
||||
return token
|
||||
}
|
||||
|
||||
if time.Now().UTC().Add(s.expire).Unix() > token.Issued {
|
||||
return nil
|
||||
}
|
||||
return token
|
||||
}
|
||||
|
||||
// getToken is a helper function that extracts the token
|
||||
|
@ -1,7 +1,6 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
Loading…
x
Reference in New Issue
Block a user