Refactor merge conan and container auth preserve actions taskID (#36560)
* Remove duplicated code * Allow further ActionsUser package permission checks --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -23,21 +23,24 @@ type packageClaims struct {
|
||||
PackageMeta
|
||||
}
|
||||
type PackageMeta struct {
|
||||
UserID int64
|
||||
Scope auth_model.AccessTokenScope
|
||||
UserID int64
|
||||
Scope auth_model.AccessTokenScope
|
||||
ActionsUserTaskID int64
|
||||
}
|
||||
|
||||
func CreateAuthorizationToken(u *user_model.User, packageScope auth_model.AccessTokenScope) (string, error) {
|
||||
now := time.Now()
|
||||
|
||||
actionsUserTaskID, _ := user_model.GetActionsUserTaskID(u)
|
||||
claims := packageClaims{
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(now.Add(24 * time.Hour)),
|
||||
NotBefore: jwt.NewNumericDate(now),
|
||||
},
|
||||
PackageMeta: PackageMeta{
|
||||
UserID: u.ID,
|
||||
Scope: packageScope,
|
||||
UserID: u.ID,
|
||||
Scope: packageScope,
|
||||
ActionsUserTaskID: actionsUserTaskID,
|
||||
},
|
||||
}
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
|
||||
Reference in New Issue
Block a user