Skip to content

Commit f24e9ed

Browse files
Merge pull request #5179 from indeewari/feature/application-revocation
Revoke application artifacts through administration flows
2 parents edaf54c + 8d78740 commit f24e9ed

81 files changed

Lines changed: 5657 additions & 2056 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/.mockery.public.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,16 @@ packages:
404404
pkgname: flowmgtmock
405405
filename: "{{.InterfaceName}}_mock.go"
406406

407+
# Only the registry is mocked outside this package. The rest of the executor interfaces are internal
408+
# seams, and one of them names an unexported type, which a mock in another package cannot reference.
407409
github.com/thunder-id/thunderid/internal/flow/executor:
408410
config:
409-
all: true
410411
dir: tests/mocks/flow/executormock
411412
structname: '{{.InterfaceName}}Mock'
412413
pkgname: executormock
413414
filename: "{{.InterfaceName}}_mock.go"
415+
interfaces:
416+
ExecutorRegistryInterface:
414417

415418
github.com/thunder-id/thunderid/internal/flow/interceptor:
416419
config:

backend/cmd/server/bootstrap/01-default-resources.yaml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,168 @@ nodes:
19911991
x: 1740
19921992
y: 200
19931993
---
1994+
resource_type: flow
1995+
id: 01900000-0000-7000-8000-000000000079
1996+
name: Default Application Deletion Flow
1997+
handle: default-application-deletion-flow
1998+
flowType: ADMINISTRATION
1999+
nodes:
2000+
- id: start
2001+
type: START
2002+
onSuccess: permission_validator
2003+
layout:
2004+
size:
2005+
width: 101
2006+
height: 34
2007+
position:
2008+
x: 100
2009+
y: 200
2010+
- id: permission_validator
2011+
type: TASK_EXECUTION
2012+
executor:
2013+
name: PermissionValidator
2014+
onSuccess: validate_application_deletion
2015+
layout:
2016+
size:
2017+
width: 206
2018+
height: 113
2019+
position:
2020+
x: 300
2021+
y: 175
2022+
- id: validate_application_deletion
2023+
type: TASK_EXECUTION
2024+
executor:
2025+
name: ApplicationActionValidator
2026+
mode: revoke_all
2027+
onSuccess: revoke_tokens
2028+
layout:
2029+
size:
2030+
width: 240
2031+
height: 113
2032+
position:
2033+
x: 580
2034+
y: 175
2035+
- id: revoke_tokens
2036+
type: TASK_EXECUTION
2037+
executor:
2038+
name: CriteriaRevocationExecutor
2039+
onSuccess: revoke_sessions
2040+
layout:
2041+
size:
2042+
width: 206
2043+
height: 113
2044+
position:
2045+
x: 900
2046+
y: 175
2047+
- id: revoke_sessions
2048+
type: TASK_EXECUTION
2049+
executor:
2050+
name: SessionRevocationExecutor
2051+
onSuccess: delete_application
2052+
layout:
2053+
size:
2054+
width: 206
2055+
height: 113
2056+
position:
2057+
x: 1180
2058+
y: 175
2059+
- id: delete_application
2060+
type: TASK_EXECUTION
2061+
executor:
2062+
name: ApplicationDeleteExecutor
2063+
onSuccess: end
2064+
layout:
2065+
size:
2066+
width: 220
2067+
height: 113
2068+
position:
2069+
x: 1460
2070+
y: 175
2071+
- id: end
2072+
type: END
2073+
layout:
2074+
size:
2075+
width: 85
2076+
height: 34
2077+
position:
2078+
x: 1760
2079+
y: 200
2080+
---
2081+
resource_type: flow
2082+
id: 01900000-0000-7000-8000-00000000007a
2083+
name: Default Secret Regeneration Flow
2084+
handle: default-secret-regeneration-flow
2085+
flowType: ADMINISTRATION
2086+
nodes:
2087+
- id: start
2088+
type: START
2089+
onSuccess: permission_validator
2090+
layout:
2091+
size:
2092+
width: 101
2093+
height: 34
2094+
position:
2095+
x: 100
2096+
y: 200
2097+
- id: permission_validator
2098+
type: TASK_EXECUTION
2099+
executor:
2100+
name: PermissionValidator
2101+
onSuccess: validate_secret_regeneration
2102+
layout:
2103+
size:
2104+
width: 206
2105+
height: 113
2106+
position:
2107+
x: 300
2108+
y: 175
2109+
- id: validate_secret_regeneration
2110+
type: TASK_EXECUTION
2111+
executor:
2112+
name: ApplicationActionValidator
2113+
mode: revoke_before_action
2114+
onSuccess: revoke_tokens
2115+
layout:
2116+
size:
2117+
width: 250
2118+
height: 113
2119+
position:
2120+
x: 580
2121+
y: 175
2122+
- id: revoke_tokens
2123+
type: TASK_EXECUTION
2124+
executor:
2125+
name: CriteriaRevocationExecutor
2126+
onSuccess: regenerate_secret
2127+
layout:
2128+
size:
2129+
width: 206
2130+
height: 113
2131+
position:
2132+
x: 920
2133+
y: 175
2134+
- id: regenerate_secret
2135+
type: TASK_EXECUTION
2136+
executor:
2137+
name: ClientSecretExecutor
2138+
onSuccess: end
2139+
layout:
2140+
size:
2141+
width: 250
2142+
height: 113
2143+
position:
2144+
x: 1200
2145+
y: 175
2146+
- id: end
2147+
type: END
2148+
layout:
2149+
size:
2150+
width: 85
2151+
height: 34
2152+
position:
2153+
x: 1520
2154+
y: 200
2155+
---
19942156
resource_type: theme
19952157
id: 01900000-0000-7000-8000-000000000071
19962158
handle: acrylic-orange

backend/cmd/server/bootstrap/02-server-configurations.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ value:
1616
expirySeconds: 86400
1717
userDeletionFlow:
1818
defaultHandle: default-user-deletion-flow
19+
applicationDeletionFlow:
20+
defaultHandle: default-application-deletion-flow
21+
secretRegenerationFlow:
22+
defaultHandle: default-secret-regeneration-flow

backend/cmd/server/servicemanager.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import (
6464
"github.com/thunder-id/thunderid/internal/oauth/oauth2/dpop"
6565
"github.com/thunder-id/thunderid/internal/oauth/oauth2/jti"
6666
"github.com/thunder-id/thunderid/internal/oauth/oauth2/revocation"
67+
"github.com/thunder-id/thunderid/internal/oauth/oauth2/tokenservice"
6768
"github.com/thunder-id/thunderid/internal/openid4vci"
6869
"github.com/thunder-id/thunderid/internal/ou"
6970
"github.com/thunder-id/thunderid/internal/resource"
@@ -417,8 +418,14 @@ func registerServices(mux *http.ServeMux, cacheManager cache.CacheManagerInterfa
417418

418419
applicationService, applicationExporter, err := application.Initialize(
419420
mux, mcpServer, entityService, inboundClientService, ouService, i18nService,
420-
runtimeCryptoSvc, serverConfigService)
421+
runtimeCryptoSvc, serverConfigService,
422+
func(client *providers.OAuthClient) time.Duration {
423+
return tokenservice.ArtifactLifetime(oauthCfg, client)
424+
})
421425
fatalOnError(ctx, logger, err, "Failed to initialize ApplicationService")
426+
// Two-phase initialization: inject the application service into the executors that act on it.
427+
fatalOnError(ctx, logger, executor.SetApplicationProvider(execRegistry, applicationService),
428+
"Failed to inject the application provider into the flow executors")
422429
exporters = append(exporters, applicationExporter)
423430

424431
agentService, agentExporter, err := agent.Initialize(mux, entityService, inboundClientService, ouService,

backend/dbscripts/runtime_persistent/postgres.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ CREATE TABLE "SSO_SESSION_PARTICIPANT" (
9595
PRIMARY KEY (SESSION_ID, DEPLOYMENT_ID, APP_ID)
9696
);
9797

98+
-- Index for participation lookups by application, used when an application is deleted and its
99+
-- participation must be detached from every session it joined.
100+
CREATE INDEX idx_sso_session_participant_app ON "SSO_SESSION_PARTICIPANT" (DEPLOYMENT_ID, APP_ID);
101+
98102
-- Table to store consent records.
99103
CREATE TABLE "CONSENT" (
100104
DEPLOYMENT_ID VARCHAR(255) NOT NULL,

backend/dbscripts/runtime_persistent/sqlite.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ CREATE TABLE "SSO_SESSION_PARTICIPANT" (
9595
PRIMARY KEY (SESSION_ID, DEPLOYMENT_ID, APP_ID)
9696
);
9797

98+
-- Index for participation lookups by application, used when an application is deleted and its
99+
-- participation must be detached from every session it joined.
100+
CREATE INDEX idx_sso_session_participant_app ON "SSO_SESSION_PARTICIPANT" (DEPLOYMENT_ID, APP_ID);
101+
98102
-- Table to store consent records.
99103
CREATE TABLE "CONSENT" (
100104
DEPLOYMENT_ID VARCHAR(255) NOT NULL,

0 commit comments

Comments
 (0)