mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:57:33 +00:00
fix: access tokens for service users and refresh token infos (#1779)
* fix: access token for service user * handle info from refresh request * uniqueness * postpone access token uniqueness change
This commit is contained in:
@@ -24,14 +24,14 @@ const (
|
||||
)
|
||||
|
||||
type RefreshTokenView struct {
|
||||
ID string `json:"tokenId" gorm:"column:id"`
|
||||
ID string `json:"tokenId" gorm:"column:id;primary_key"`
|
||||
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
|
||||
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
|
||||
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||
Token string `json:"-" gorm:"column:token"`
|
||||
UserID string `json:"-" gorm:"column:user_id;primary_key"`
|
||||
ClientID string `json:"clientID" gorm:"column:client_id;primary_key"`
|
||||
UserAgentID string `json:"userAgentId" gorm:"column:user_agent_id;primary_key"`
|
||||
UserID string `json:"-" gorm:"column:user_id"`
|
||||
ClientID string `json:"clientID" gorm:"column:client_id"`
|
||||
UserAgentID string `json:"userAgentId" gorm:"column:user_agent_id"`
|
||||
Audience pq.StringArray `json:"audience" gorm:"column:audience"`
|
||||
Scopes pq.StringArray `json:"scopes" gorm:"column:scopes"`
|
||||
AuthMethodsReferences pq.StringArray `json:"authMethodsReference" gorm:"column:amr"`
|
||||
|
@@ -1,13 +1,14 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/user/model"
|
||||
usr_model "github.com/caos/zitadel/internal/user/repository/view/model"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
func RefreshTokenByID(db *gorm.DB, table, tokenID string) (*usr_model.RefreshTokenView, error) {
|
||||
@@ -35,7 +36,10 @@ func RefreshTokensByUserID(db *gorm.DB, table, userID string) ([]*usr_model.Refr
|
||||
}
|
||||
|
||||
func PutRefreshToken(db *gorm.DB, table string, token *usr_model.RefreshTokenView) error {
|
||||
save := repository.PrepareSave(table)
|
||||
save := repository.PrepareSaveOnConflict(table,
|
||||
[]string{"client_id", "user_agent_id", "user_id"},
|
||||
[]string{"id", "creation_date", "change_date", "token", "auth_time", "idle_expiration", "expiration", "sequence", "scopes", "audience", "amr"},
|
||||
)
|
||||
return save(db, token)
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,14 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/user/model"
|
||||
usr_model "github.com/caos/zitadel/internal/user/repository/view/model"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
func TokenByID(db *gorm.DB, table, tokenID string) (*usr_model.TokenView, error) {
|
||||
|
Reference in New Issue
Block a user