mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
feat: add possibility to set an expiration to a session (#6851)
* add lifetime to session api * extend session with lifetime * check session token expiration * fix typo * integration test to check session token expiration * integration test to check session token expiration * i18n * cleanup * improve tests * prevent negative lifetime * fix error message * fix lifetime check
This commit is contained in:
@@ -28,6 +28,7 @@ const (
|
||||
OTPEmailCheckedType = sessionEventPrefix + "otp.email.checked"
|
||||
TokenSetType = sessionEventPrefix + "token.set"
|
||||
MetadataSetType = sessionEventPrefix + "metadata.set"
|
||||
LifetimeSetType = sessionEventPrefix + "lifetime.set"
|
||||
TerminateType = sessionEventPrefix + "terminated"
|
||||
)
|
||||
|
||||
@@ -607,6 +608,39 @@ func MetadataSetEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
return added, nil
|
||||
}
|
||||
|
||||
type LifetimeSetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Lifetime time.Duration `json:"lifetime"`
|
||||
}
|
||||
|
||||
func (e *LifetimeSetEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *LifetimeSetEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *LifetimeSetEvent) SetBaseEvent(base *eventstore.BaseEvent) {
|
||||
e.BaseEvent = *base
|
||||
}
|
||||
|
||||
func NewLifetimeSetEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
lifetime time.Duration,
|
||||
) *LifetimeSetEvent {
|
||||
return &LifetimeSetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LifetimeSetType,
|
||||
),
|
||||
Lifetime: lifetime,
|
||||
}
|
||||
}
|
||||
|
||||
type TerminateEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user