mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-29 15:38:52 +00:00
feat: add delete session on relation tables (#11334)
# Which Problems Are Solved As part of moving the session API to the relational database, this PR adds the functionality to delete sessions through the session API v2 and the OIDC end_session endpoint. # How the Problems Are Solved - added `SessionDeleteCommand` in domain package - added possibility to pass the session token verifier to the domain package - use feature flag to switch API and OIDC usage from CQRS to relation table - added a `permissionCheck` condition to let permissions be checked directly in the repository / sql - part of it is still a placeholder until actual permission tables are done - added a `session_deleted` table to store (recently) deleted sessions to handle necessary checks / cases like delete my own session, which needs to be idempotent # Additional Changes Fixed `Matches` function of `existsCondition` (as missing an implementation) # Additional Context - closes #11037 --------- Co-authored-by: Stefan Benz <[email protected]>
This commit is contained in:
co-authored by
Stefan Benz
parent
ae32508225
commit
ca4bba3992
@@ -313,8 +313,14 @@ type existsCondition struct {
|
||||
|
||||
// Matches implements [Condition].
|
||||
func (e *existsCondition) Matches(x any) bool {
|
||||
// Unimplemented
|
||||
return false
|
||||
toMatch, ok := x.(*existsCondition)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if e.table != toMatch.table {
|
||||
return false
|
||||
}
|
||||
return e.condition.Matches(toMatch.condition)
|
||||
}
|
||||
|
||||
// String implements [Condition].
|
||||
@@ -364,3 +370,46 @@ func ForceRestrictingColumn(cond Condition, isRestriction bool) Condition {
|
||||
}
|
||||
|
||||
var _ Condition = (*forcedRestrictingColumnCondition)(nil)
|
||||
|
||||
type permissionCheck struct {
|
||||
requiredPermission string
|
||||
throwError bool
|
||||
}
|
||||
|
||||
func (p *permissionCheck) Matches(x any) bool {
|
||||
toMatch, ok := x.(*permissionCheck)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if toMatch.requiredPermission != p.requiredPermission {
|
||||
return false
|
||||
}
|
||||
return toMatch.throwError == p.throwError
|
||||
}
|
||||
|
||||
func (p *permissionCheck) String() string {
|
||||
return "database.permissionCheck"
|
||||
}
|
||||
|
||||
func (p *permissionCheck) Write(builder *StatementBuilder) {
|
||||
// TODO: implement actual permission check once we have the necessary tables and functions in place.
|
||||
// For now, we just write a dummy condition that can be used to verify that the permission check is included in the generated SQL.
|
||||
if p.throwError {
|
||||
builder.WriteString(" zitadel.throw_not_permitted() ")
|
||||
return
|
||||
}
|
||||
builder.WriteString(" true ")
|
||||
}
|
||||
|
||||
func (p *permissionCheck) IsRestrictingColumn(_ Column) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func PermissionCheck(requiredPermission string, throwError bool) *permissionCheck {
|
||||
return &permissionCheck{
|
||||
requiredPermission: requiredPermission,
|
||||
throwError: throwError,
|
||||
}
|
||||
}
|
||||
|
||||
var _ Condition = (*permissionCheck)(nil)
|
||||
|
||||
Reference in New Issue
Block a user