mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:47:33 +00:00
feat: jwt as idp (#2363)
* feat: jwt idp * feat: command side * feat: add tests * fill idp views with jwt idps and return apis * add jwtEndpoint to jwt idp * begin jwt request handling * merge * handle jwt idp * cleanup * fixes * autoregister * get token from specific header name * error handling * fix texts * handle renderExternalNotFoundOption Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
This commit is contained in:
@@ -75,6 +75,8 @@ func RegisterEventMappers(es *eventstore.Eventstore) {
|
||||
RegisterFilterEventMapper(IDPConfigReactivatedEventType, IDPConfigReactivatedEventMapper).
|
||||
RegisterFilterEventMapper(IDPOIDCConfigAddedEventType, IDPOIDCConfigAddedEventMapper).
|
||||
RegisterFilterEventMapper(IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper).
|
||||
RegisterFilterEventMapper(IDPJWTConfigAddedEventType, IDPJWTConfigAddedEventMapper).
|
||||
RegisterFilterEventMapper(IDPJWTConfigChangedEventType, IDPJWTConfigChangedEventMapper).
|
||||
RegisterFilterEventMapper(FeaturesSetEventType, FeaturesSetEventMapper).
|
||||
RegisterFilterEventMapper(FeaturesRemovedEventType, FeaturesRemovedEventMapper)
|
||||
}
|
||||
|
87
internal/repository/org/idp_jwt_config.go
Normal file
87
internal/repository/org/idp_jwt_config.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/repository"
|
||||
"github.com/caos/zitadel/internal/repository/idpconfig"
|
||||
)
|
||||
|
||||
const (
|
||||
IDPJWTConfigAddedEventType eventstore.EventType = "org.idp." + idpconfig.JWTConfigAddedEventType
|
||||
IDPJWTConfigChangedEventType eventstore.EventType = "org.idp." + idpconfig.JWTConfigChangedEventType
|
||||
)
|
||||
|
||||
type IDPJWTConfigAddedEvent struct {
|
||||
idpconfig.JWTConfigAddedEvent
|
||||
}
|
||||
|
||||
func NewIDPJWTConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID,
|
||||
jwtEndpoint,
|
||||
issuer,
|
||||
keysEndpoint,
|
||||
headerName string,
|
||||
) *IDPJWTConfigAddedEvent {
|
||||
|
||||
return &IDPJWTConfigAddedEvent{
|
||||
JWTConfigAddedEvent: *idpconfig.NewJWTConfigAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPJWTConfigAddedEventType,
|
||||
),
|
||||
idpConfigID,
|
||||
jwtEndpoint,
|
||||
issuer,
|
||||
keysEndpoint,
|
||||
headerName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func IDPJWTConfigAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e, err := idpconfig.JWTConfigAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPJWTConfigAddedEvent{JWTConfigAddedEvent: *e.(*idpconfig.JWTConfigAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type IDPJWTConfigChangedEvent struct {
|
||||
idpconfig.JWTConfigChangedEvent
|
||||
}
|
||||
|
||||
func NewIDPJWTConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
changes []idpconfig.JWTConfigChanges,
|
||||
) (*IDPJWTConfigChangedEvent, error) {
|
||||
changeEvent, err := idpconfig.NewJWTConfigChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPJWTConfigChangedEventType),
|
||||
idpConfigID,
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IDPJWTConfigChangedEvent{JWTConfigChangedEvent: *changeEvent}, nil
|
||||
}
|
||||
|
||||
func IDPJWTConfigChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e, err := idpconfig.JWTConfigChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPJWTConfigChangedEvent{JWTConfigChangedEvent: *e.(*idpconfig.JWTConfigChangedEvent)}, nil
|
||||
}
|
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
const (
|
||||
IDPOIDCConfigAddedEventType eventstore.EventType = "org.idp." + idpconfig.OIDCConfigAddedEventType
|
||||
IDPOIDCConfigChangedEventType eventstore.EventType = "org.idp." + idpconfig.ConfigChangedEventType
|
||||
IDPOIDCConfigChangedEventType eventstore.EventType = "org.idp." + idpconfig.OIDCConfigChangedEventType
|
||||
)
|
||||
|
||||
type IDPOIDCConfigAddedEvent struct {
|
||||
|
Reference in New Issue
Block a user