Compare commits

...

24 commits

Author SHA1 Message Date
d972b3846c adds tip for admin permissions 2025-03-10 10:38:37 +01:00
68166e110e adds defaultClientScopes to forgejo-client-payload.json 2025-03-05 14:46:11 +01:00
c298530caa fixes syntax error 2025-03-05 12:39:34 +01:00
6b18ed0443 adds external secret for forgejo client 2025-03-04 12:41:32 +01:00
d0fb858a81 debugging 2025-03-03 13:40:34 +01:00
b804f2293f extends keycloak-config.yaml 2025-02-27 13:32:12 +01:00
a2b3e0cbd3 testing 2025-02-27 13:15:27 +01:00
b6677f4b63 Merge branch 'development' into IPCEICIS-2293_oidc_in_forgejo 2025-02-27 13:07:48 +01:00
fd0df35b1a forgejo oauth uses existing secret 2025-02-26 16:48:18 +01:00
1b565de935 forgejo config for sso 2025-02-26 16:32:55 +01:00
d22ea7c82a debugging 2025-02-25 15:45:17 +01:00
95c45ded96 debugging 2025-02-25 15:18:35 +01:00
45f84b30b1 debugging 2025-02-25 15:12:19 +01:00
3c65ec704e debugging 2025-02-25 14:59:27 +01:00
f3ad8444e8 debugging 2025-02-25 14:52:24 +01:00
bc3a5ee0e2 debugging 2025-02-25 14:46:48 +01:00
456dc397f8 debugging 2025-02-25 14:39:32 +01:00
109198d96f debugging 2025-02-25 14:33:32 +01:00
c2fa44adc3 debugging 2025-02-25 14:06:38 +01:00
348a27d7c0 debugging 2025-02-25 14:01:01 +01:00
97f4eb33d9 debugging 2025-02-25 13:24:24 +01:00
d657841913 debugging 2025-02-25 12:31:04 +01:00
8b93796afe debugging 2025-02-25 12:19:46 +01:00
ca54424fc4 adds sso config for forgejo 2025-02-25 11:34:44 +01:00
3 changed files with 105 additions and 6 deletions

View file

@ -0,0 +1,21 @@
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: auth-generic-oauth-secret
namespace: gitea
spec:
secretStoreRef:
name: keycloak
kind: ClusterSecretStore
refreshInterval: "0"
target:
name: auth-generic-oauth-secret
template:
engineVersion: v2
data:
client_secret: "{{.FORGEJO_CLIENT_SECRET}}"
data:
- secretKey: FORGEJO_CLIENT_SECRET
remoteRef:
key: keycloak-clients
property: FORGEJO_CLIENT_SECRET

View file

@ -27,6 +27,17 @@ gitea:
server:
DOMAIN: '{{{ .Env.DOMAIN_GITEA }}}'
ROOT_URL: 'https://{{{ .Env.DOMAIN_GITEA }}}:443'
oauth2_client:
ENABLE_AUTO_REGISTRATION: true
ACCOUNT_LINKING: auto
# oauth:
# - name: 'Keycloak'
# provider: 'openidConnect'
# # key: 'forgejo'
# # secret: 'uWEGALJKmNyUojJaK5LAK0w4OCEEDpDu'
# existingSecret: forgejo-oidc
# autoDiscoverUrl: 'https://{{{ .Env.DOMAIN }}}/keycloak/realms/cnoe/.well-known/openid-configuration'
# # admin-group: is to specify which keycloak group has forgejo admin permissions
service:
ssh:

View file

@ -100,11 +100,11 @@ data:
user-user1.json: |
{
"username": "user1",
"email": "",
"email": "user1@user.de",
"firstName": "user",
"lastName": "one",
"requiredActions": [],
"emailVerified": false,
"emailVerified": true,
"groups": [
"/admin"
],
@ -113,11 +113,11 @@ data:
user-user2.json: |
{
"username": "user2",
"email": "",
"email": "user2@user.de",
"firstName": "user",
"lastName": "two",
"requiredActions": [],
"emailVerified": false,
"emailVerified": true,
"groups": [
"/base-user"
],
@ -181,6 +181,44 @@ data:
]
}
forgejo-client-payload.json: |
{
"protocol": "openid-connect",
"clientId": "forgejo",
"name": "Forgejo Client",
"description": "Used for Forgejo SSO",
"publicClient": false,
"authorizationServicesEnabled": false,
"serviceAccountsEnabled": false,
"implicitFlowEnabled": false,
"directAccessGrantsEnabled": true,
"standardFlowEnabled": true,
"frontchannelLogout": true,
"attributes": {
"saml_idp_initiated_sso_url_name": "",
"oauth2.device.authorization.grant.enabled": false,
"oidc.ciba.grant.enabled": false
},
"alwaysDisplayInConsole": false,
"rootUrl": "https://{{{ .Env.DOMAIN_GITEA }}}:443",
"baseUrl": "",
"redirectUris": [
"https://{{{ .Env.DOMAIN_GITEA }}}/*"
],
"webOrigins": [
"/*"
]
"defaultClientScopes": [
"web-origins",
"acr",
"offline_access",
"roles",
"profile",
"groups",
"email"
]
}
---
apiVersion: batch/v1
kind: Job
@ -341,12 +379,39 @@ spec:
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients | jq -e -r '.[] | select(.clientId == "backstage") | .id')
CLIENT_SCOPE_GROUPS_ID=$(curl -sS -H "Content-Type: application/json" -H "Authorization: bearer ${KEYCLOAK_TOKEN}" -X GET ${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes | jq -e -r '.[] | select(.name == "groups") | .id')
curl -sS -H "Content-Type: application/json" -H "Authorization: bearer ${KEYCLOAK_TOKEN}" -X PUT ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID}/default-client-scopes/${CLIENT_SCOPE_GROUPS_ID}
CLIENT_SCOPE_GROUPS_ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes | jq -e -r '.[] | select(.name == "groups") | .id')
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X PUT ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID}/default-client-scopes/${CLIENT_SCOPE_GROUPS_ID}
BACKSTAGE_CLIENT_SECRET=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID} | jq -e -r '.secret')
echo "creating Forgejo client"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/forgejo-client-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/clients
CLIENT_ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients | jq -e -r '.[] | select(.clientId == "forgejo") | .id')
CLIENT_SCOPE_GROUPS_ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes | jq -e -r '.[] | select(.name == "groups") | .id')
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X PUT ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID}/default-client-scopes/${CLIENT_SCOPE_GROUPS_ID}
FORGEJO_CLIENT_SECRET=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID} | jq -e -r '.secret')
ARGOCD_PASSWORD=$(./kubectl -n argocd get secret argocd-initial-admin-secret -o go-template='{{.data.password | base64decode }}')
@ -365,6 +430,8 @@ spec:
ARGOCD_SESSION_TOKEN: ${ARGOCD_SESSION_TOKEN}
BACKSTAGE_CLIENT_SECRET: ${BACKSTAGE_CLIENT_SECRET}
BACKSTAGE_CLIENT_ID: backstage
FORGEJO_CLIENT_SECRET: ${FORGEJO_CLIENT_SECRET}
FORGEJO_CLIENT_ID: forgejo
" > /tmp/secret.yaml
./kubectl apply -f /tmp/secret.yaml