Create Keycloak service account for programmatic admin API access #260
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/pal-e-platform#260
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
Standalone — discovered while trying to send test emails via basketball-api admin endpoints. No programmatic auth path exists.
westside-appis a public client (PKCE only),admin-clion master realm doesn't pass JWT validation against service realm JWKS.Repo
forgejo_admin/pal-e-services(Keycloak clients are managed via Terraform in pal-e-services, not pal-e-platform)User Story
As a platform operator,
I want a service account that can authenticate programmatically against Keycloak
So that CLI tools, agents, and scripts can hit admin API endpoints without a browser login flow.
Context
Basketball-api admin endpoints (email blast, schedule CRUD, user management) require a JWT with the
adminrole in thewestside-basketballrealm. Currently the only way to get one is browser login viawestside-app(public client, PKCE) — not scriptable.The infrastructure already exists.
pal-e-services/terraform/keycloak.tfhas:keycloak_openid_clientwithservice_accounts_enabledsupportkeycloak_openid_client_service_account_realm_rolefor role bindingk3s.tfvars.example(lines 42-49)This is a 5-line tfvars addition +
tofu apply.Environment
keycloak.tail5b443a.ts.netwestside-basketball~/pal-e-services/terraform/mrparkers/keycloakFile Targets
Files to modify:
~/pal-e-services/terraform/k3s.tfvars— addplatform-serviceclient entry tokeycloak_clientsmapFiles NOT to touch:
keycloak.tf— resources already support service accountsvariables.tf— variable schema already supports all needed fieldsPost-apply:
tofu output~/secrets/pal-e-services/keycloak-service-account.envsop-keycloak-service-accountAcceptance Criteria
platform-serviceentry added tokeycloak_clientsin k3s.tfvarstofu planshows 3 new resources (client, role mapper, service account role binding)tofu applysucceedscurl -X POST .../token -d grant_type=client_credentials -d client_id=platform-service -d client_secret=...~/secrets/pal-e-services/keycloak-service-account.envTest Expectations
curl -X POST /admin/email/welcome-practice?test_email=draneylucas@gmail.comwith service account token returns 200adminrole inrealm_access.rolestofu plan -lock=false -var-file=k3s.tfvarsConstraints
client_credentialsgrant, NOTpasswordgrantk3s.tfvars.examplelines 42-49tofu plan -lock=falsebefore applyChecklist
Related
pal-e-platform— project this affectsScope Review: BLOCK
Review note:
review-785-2026-04-03Core assumption is invalid.
k3s.tfvarsalready containswestside-ai-bot— a confidential service account client withservice_accounts_enabled = trueandservice_account_realm_roles = ["admin"]in thewestside-basketballrealm (lines 102-112). This is exactly what the ticket proposes to create.Issues found:
westside-ai-botalready satisfies this need before creating a duplicate client. If a separate client is justified, explain why in the Context section.story:platform-S1does not exist in project-pal-e-platform user stories. Change tostory:superuser-deployorstory:superuser-onboard-service.arch-keycloakarchitecture note exists in pal-e-docs — create it.pal-e-platformbut work is inpal-e-services. Refile on correct repo.