mayope / keycloakmigration

Manage your Keycloak configuration with code.
https://mayope.net
MIT License
106 stars 21 forks source link

Add plain delete object #73

Open logabot opened 1 year ago

logabot commented 1 year ago

I have mistake in my import file.

...
clients: {[
  "id": "super-service-account",
  "clientId": "super-service-account",
...
]}

And now, i can't delete this cleint because:


[ERROR] 2023-06-28 15:46:17.750 [main] KeycloakMigration - Error occurred while migrating: from-16-to-19 
feign.FeignException: Cannot deserialize value of type `java.util.UUID` from String "super-service-account": UUID has to be represented by standard 36-char representation
 at [Source: (BufferedReader); line: 1, column: 3314] (through reference chain: java.util.ArrayList[4]->de.klg71.keycloakmigration.keycloakapi.model.ClientListItem["id"])```

Can you add some method to delete without "validate" it. Maybe by http request or something else?
klg71 commented 1 year ago

Hey @logabot thanks for opening this issue :) could you share your complete yaml file?

logabot commented 1 year ago

@klg71 This error happend bacuse my previos imported file has filled clients.id field. In db

                  id                  |       client_id
--------------------------------------+------------------------
 super-service-account                | super-service-account

migration.yml

id: from-16-to-19
author: logabot
changes:
- updateClient:
    realm: master
    clientId: account
    rootUrl: ${authBaseUrl}
- updateClient:
    realm: master
    clientId: account-console
    rootUrl: "${authBaseUrl}"
- updateClient:
    realm: master
    clientId: security-admin-console
    rootUrl: '${authBaseUrl}'
- deleteClient:
    realm: prodRealm
    clientId: super-service-account
- importClient:
    realm: prodRealm
    clientRepresentationJsonFilename: custom-service-account.json
- importClient:
    realm: prodRealm
    clientRepresentationJsonFilename: account-console.json
- updateClient:
    realm: prodRealm
    clientId: account
    rootUrl: ${authBaseUrl}
- updateClient:
    realm: prodRealm
    clientId: account-console
    rootUrl: "${authBaseUrl}"
- updateClient:
    realm: prodRealm
    clientId: security-admin-console
    rootUrl: "${authBaseUrl}"

custom-service-account.json

{
  "clientId": "super-service-account",
  "name": "",
  "description": "ttt",
  "rootUrl": "",
  "adminUrl": "",
  "baseUrl": "",
  "surrogateAuthRequired": false,
  "enabled": true,
  "alwaysDisplayInConsole": false,
  "clientAuthenticatorType": "client-secret",
  "secret": "b4b5e588-3586-4361-b636-2e66824dae3c",
  "redirectUris": [],
  "webOrigins": [
    "<redacted>"
  ],
  "notBefore": 0,
  "bearerOnly": false,
  "consentRequired": false,
  "standardFlowEnabled": false,
  "implicitFlowEnabled": false,
  "directAccessGrantsEnabled": true,
  "serviceAccountsEnabled": true,
  "publicClient": false,
  "frontchannelLogout": false,
  "protocol": "openid-connect",
  "attributes": {
    "oidc.ciba.grant.enabled": "false",
    "oauth2.device.authorization.grant.enabled": "false",
    "display.on.consent.screen": "false",
    "backchannel.logout.session.required": "true",
    "backchannel.logout.revoke.offline.tokens": "false"
  },
  "authenticationFlowBindingOverrides": {},
  "fullScopeAllowed": true,
  "nodeReRegistrationTimeout": -1,
  "protocolMappers": [
    {
      "name": "Client Host",
      "protocol": "openid-connect",
      "protocolMapper": "oidc-usersessionmodel-note-mapper",
      "consentRequired": false,
      "config": {
        "user.session.note": "clientHost",
        "id.token.claim": "true",
        "access.token.claim": "true",
        "claim.name": "clientHost",
        "jsonType.label": "String"
      }
    },
    {
      "name": "Client ID",
      "protocol": "openid-connect",
      "protocolMapper": "oidc-usersessionmodel-note-mapper",
      "consentRequired": false,
      "config": {
        "user.session.note": "clientId",
        "id.token.claim": "true",
        "access.token.claim": "true",
        "claim.name": "clientId",
        "jsonType.label": "String"
      }
    },
    {
      "name": "Client IP Address",
      "protocol": "openid-connect",
      "protocolMapper": "oidc-usersessionmodel-note-mapper",
      "consentRequired": false,
      "config": {
        "user.session.note": "clientAddress",
        "id.token.claim": "true",
        "access.token.claim": "true",
        "claim.name": "clientAddress",
        "jsonType.label": "String"
      }
    }
  ],
  "defaultClientScopes": [
    "web-origins",
    "profile",
    "roles",
    "email"
  ],
  "optionalClientScopes": [
    "address",
    "phone",
    "offline_access",
    "microprofile-jwt"
  ],
  "access": {
    "view": true,
    "configure": true,
    "manage": true
  }
}