Interface AuthBackend
AuthService resolves one AuthBackend implementation per call (based on the persisted
AuthBackendStore.Config#cognitoEnabled() flag) and delegates its user-management
methods (listUsers/createLocalUser/updateUser/revokeSessions/
deleteUser) through it.
Deliberately scoped to exactly this — Users-page CRUD — and nothing else. Caller/session
resolution during normal request handling (AuthService.resolveCaller/
ensureOidcUser) branches only on authMode() (the *sign-in* mechanism: none/alb-oidc/
application-oidc) and always resolves through the local manager_user table regardless of
which AuthBackend is active for account CRUD — a Cognito-backend-enabled account still
signs in via whatever OIDC flow authMode configures, gets upserted into the local table
on each successful principal, and its Caller/role come from that local row. Moving
caller/session resolution into this interface would be a separate behavior change.
Implementations: LocalH2AuthBackend (wraps UserStore+SessionManager)
and CognitoAuthBackend (wraps CognitoUserManagementService), both in
cloudforge-manager — this interface and its DTOs (AuthAccount, AuthAccountRequest, AuthAccountUpdate) live in cloudforge-core because they're
plain contracts with no Spring/persistence dependency, following the same split as
ApplicationSpec/DatabaseSpec.
-
Method Summary
Modifier and TypeMethodDescriptioncreateAccount(AuthAccountRequest request) voiddeleteAccount(String accountId) default Optional<AuthAccount> findAccount(String accountId) Finds one account by itsAuthAccount.id(), or empty if this backend has no such account.default List<AuthAccount> listAccounts(String search, String role) Same aslistAccounts(), narrowed by two optional filters:search(matchesAuthAccount.username()/AuthAccount.email()/AuthAccount.displayName(), case-insensitive substring) androle(exact match).default voidOne-time setup a backend needs before it can accept migrated-in accounts (e.g.revokeSessions(String accountId) Invalidates every active session/token for this account without deleting it — the local equivalent of Cognito'sAdminUserGlobalSignOut.updateAccount(String accountId, AuthAccountUpdate update)
-
Method Details
-
listAccounts
List<AuthAccount> listAccounts() -
listAccounts
Same aslistAccounts(), narrowed by two optional filters:search(matchesAuthAccount.username()/AuthAccount.email()/AuthAccount.displayName(), case-insensitive substring) androle(exact match). Bothnull/blank mean "unfiltered" — equivalent tolistAccounts().The default implementation filters in Java over
listAccounts()— correct for any backend, but only moves the filtering server-side (out of the Angular Users page) without reducing the underlying account-directory calls.LocalH2AuthBackendoverrides this with a database-level query.CognitoAuthBackendkeeps this default deliberately: Cognito's ownListUsersFiltersyntax has no concept of role (role lives in group membership, not a filterable user attribute), so even an override there couldn't push therolefilter down — onlysearchcould move, with no reduction in Cognito API calls either, the same trade-offCloudFormationInventory#listInstances(String, String)'ssearchparameter documents for AWS's ownListStacks. -
createAccount
-
updateAccount
-
revokeSessions
Invalidates every active session/token for this account without deleting it — the local equivalent of Cognito'sAdminUserGlobalSignOut. Returns the (unchanged) account so callers can render an up-to-date view without a second lookup. -
deleteAccount
-
prepareForIncomingMigration
default void prepareForIncomingMigration()One-time setup a backend needs before it can accept migrated-in accounts (e.g. Cognito's IAM role groups must exist before a migration starts adding users to them). Called once per migration run, before the firstcreateAccount(AuthAccountRequest). No-op by default —LocalH2AuthBackendhas nothing to prepare. -
findAccount
Finds one account by itsAuthAccount.id(), or empty if this backend has no such account. Exists so callers that only have an id — e.g. Access Control's policy-override editor, given whatever idlistAccounts()last handed the frontend — can resolve a username/role for display without requiring the account to also exist in Manager's local user table. A Cognito-only account that has never signed in through application-oidc has no local row, so a local-table lookup would report "user not found" for an accountlistAccounts()just returned.Default implementation scans
listAccounts()— correct for any backend, just not the cheapest possible lookup; override when a backend can look up a single account more directly (seeCognitoAuthBackend).
-