mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
feat(api): allow specifying access_token type (opaque/JWT) for service users (#5150)
Add functionality to configure the access token type on the service accounts to provide the oidc library with the necessary information to create the right type of access token.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
@@ -20,10 +21,11 @@ type MachineAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
UserName string `json:"userName"`
|
||||
userLoginMustBeDomain bool `json:"-"`
|
||||
userLoginMustBeDomain bool
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
AccessTokenType domain.OIDCTokenType `json:"accessTokenType,omitempty"`
|
||||
}
|
||||
|
||||
func (e *MachineAddedEvent) Data() interface{} {
|
||||
@@ -41,6 +43,7 @@ func NewMachineAddedEvent(
|
||||
name,
|
||||
description string,
|
||||
userLoginMustBeDomain bool,
|
||||
accessTokenType domain.OIDCTokenType,
|
||||
) *MachineAddedEvent {
|
||||
return &MachineAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
@@ -52,6 +55,7 @@ func NewMachineAddedEvent(
|
||||
Name: name,
|
||||
Description: description,
|
||||
userLoginMustBeDomain: userLoginMustBeDomain,
|
||||
AccessTokenType: accessTokenType,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +74,9 @@ func MachineAddedEventMapper(event *repository.Event) (eventstore.Event, error)
|
||||
type MachineChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Name *string `json:"name,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
AccessTokenType *domain.OIDCTokenType `json:"accessTokenType,omitempty"`
|
||||
}
|
||||
|
||||
func (e *MachineChangedEvent) Data() interface{} {
|
||||
@@ -117,6 +122,12 @@ func ChangeDescription(description string) func(event *MachineChangedEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeAccessTokenType(accessTokenType domain.OIDCTokenType) func(event *MachineChangedEvent) {
|
||||
return func(e *MachineChangedEvent) {
|
||||
e.AccessTokenType = &accessTokenType
|
||||
}
|
||||
}
|
||||
|
||||
func MachineChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
machineChanged := &MachineChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
|
Reference in New Issue
Block a user