You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To authenticate any api client with eda the workflow should acquiring the access token from the keycloak service that runs alongside EDA.
To acquire the token, the api client should authenticate with a known client id and client secret. As of 24.12.1, keycloak comes preconfigured with the following data
realm: eda
client: eda
To acquire the token for the eda client we need to get the client secret, which is a random value generated at keycloak creation time. Since these secrets are not hardcoded, clab connector should fetch the secret from keycloak.
We should assume that two workflows are possible:
The user already knows the client secret, they may get it from their EDA admin (the production workflow). In this case, the secret should be passed via the cli flag client-secret
The user does not know the client secret. In this case we fetch the secret from the keycloak by authenticating against the keycloak admin api as shown below
We assume that the keycloak admin credentials are admin:admin, we might want to expose these via CLI flags as well (kc-user, kc-password).
To fetch the eda client secret we should do smth like this
importhttpx# Keycloak configurationkeycloak_url="http://<keycloak-host>/auth"# Replace with your Keycloak URLrealm="master"# Keycloak realm for admin usersclient_id="admin-cli"# Default client for admin operationsusername="admin"password="admin"# Step 1: Get an access tokentoken_url=f"{keycloak_url}/realms/{realm}/protocol/openid-connect/token"token_data= {
"grant_type": "password",
"client_id": client_id,
"username": username,
"password": password,
}
headers= {"Content-Type": "application/x-www-form-urlencoded"}
defget_client_secret():
withhttpx.Client() asclient:
# Fetch access tokentoken_response=client.post(token_url, data=token_data, headers=headers)
token_response.raise_for_status()
access_token=token_response.json()["access_token"]
# Step 2: Fetch the `eda` client ID and secretadmin_api_url=f"{keycloak_url}/admin/realms/eda-realm/clients"auth_headers= {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
}
# Fetch clientsclients_response=client.get(admin_api_url, headers=auth_headers)
clients_response.raise_for_status()
clients=clients_response.json()
# Find the `eda` clienteda_client=next((clientforclientinclientsifclient["clientId"] =="eda"), None)
ifnoteda_client:
raiseException("Client `eda` not found in realm `eda-realm`")
# Fetch the client secretclient_id=eda_client["id"]
client_secret_url=f"{admin_api_url}/{client_id}/client-secret"secret_response=client.get(client_secret_url, headers=auth_headers)
secret_response.raise_for_status()
client_secret=secret_response.json()["value"]
print(f"Client ID: {client_id}")
print(f"Client Secret: {client_secret}")
# Run the functionget_client_secret()
With the eda client secret known, the request to get the api token is:
https://eda/auth/login endpoint will be deprecated. To get bearer token use the keycloack directly as documented here https://docs.eda.dev/development/api/#authentication
To authenticate any api client with eda the workflow should acquiring the access token from the keycloak service that runs alongside EDA.
To acquire the token, the api client should authenticate with a known client id and client secret. As of 24.12.1, keycloak comes preconfigured with the following data
To acquire the token for the
eda
client we need to get the client secret, which is a random value generated at keycloak creation time. Since these secrets are not hardcoded, clab connector should fetch the secret from keycloak.We should assume that two workflows are possible:
client-secret
We assume that the keycloak admin credentials are
admin:admin
, we might want to expose these via CLI flags as well (kc-user
,kc-password
).To fetch the
eda
client secret we should do smth like thisWith the
eda
client secret known, the request to get the api token is:The text was updated successfully, but these errors were encountered: