busy-mechanic-8014
03/29/2023, 9:00 AMmetadata_service_authentication:
enabled: true
systemClientId: "__datahub_system"
systemClientSecret:
secretRef: "datahub-auth-secrets"
secretKey: "token_service_signing_key"
tokenService:
signingKey:
secretRef: "datahub-auth-secrets"
secretKey: "token_service_signing_key"
salt:
secretRef: "datahub-auth-secrets"
secretKey: "token_service_salt"
# Set to false if you'd like to provide your own auth secrets
provisionSecrets:
enabled: true
autoGenerate: true
# Only specify if autoGenerate set to false
# secretValues:
# secret: <secret value>
# signingKey: <signing key value>
# salt: <salt value>
=> I’ve now a secret with token_service_signing_key: f2E0BZoNKlr7CEu71kjZjAduRNCsePKS
Create programmatically the access token
• Decode an access token created on the UI and get the payload
{
"actorType": "USER",
"actorId": "datahub",
"type": "PERSONAL",
"version": "2",
"jti": "6ec82917-d39a-4c52-9a5e-5d4caacf6b7d",
"sub": "datahub",
"exp": 1680015431,
"iss": "datahub-metadata-service"
}
• I validated the service key by recreating the token by my own means (just used https://jwt.io/ with payload, header and token signing key)
• Create a new token in Python
import jwt
import time
# I noticed that you have to encode the service key in ASCII to get the same verified signature as the token created on the UI (anyway I tested with or without for the same result)
secret_signing_key = "f2E0BZoNKlr7CEu71kjZjAduRNCsePKS".encode('ascii')
payload = {
"actorType": "USER",
"actorId": "datahub",
"type": "PERSONAL",
"version": "2",
"jti": "6ec82917-d39a-4c52-9a5e-5d4caacf6b7d",
"sub": "datahub",
"exp": 1680015431,
"iss": "datahub-metadata-service"
}
header = { "alg": "HS256" }
token = jwt.encode(payload, secret, headers=header)
print(token)
eyJhbGciOiJIUzI1NiJ9…
• Decode my new access token to check if it is well built => all looks good
*cURL (*Curl proposed when creating a token on the UI)
curl -X POST "<http://datahub-front-url/api/graphql>" --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9… ' --header 'Content-Type: application/json' --data-raw '{"query": "{\n me {\n corpUser {\n username\n }\n }\n}","variables":{}}'
=> HTTP ERROR 401 Unauthorized to perform this action
Datahub API
datahub ingest -c /tmp/ch_recipe.yml
ch_recipe.yml:
source:
type: clickhouse
config:
host_port: "clickhouse-install.clickhouse.svc.cluster.local:8123"
username: ****
password: ****
platform_instance: DatabaseNameToBeIngested
include_views: true
include_tables: true
sink:
type: "datahub-rest"
config:
server: "<http://datahub-gms.datahub.svc.cluster.local:8080>"
token: "eyJhbGciOiJIUzI1NiJ9…."
=> 401 Client Error: Unauthorized for url
All works fine if I put a token created on the UI.
Questions
Has anyone managed to create a token programmatically and used it for queries? Is it really possible to do that now?
I also noticed (if I understood correctly) that if I create a token via the UI, retrieve it but delete it immediately afterwards, it's as if I simulate creating the token programmatically and get this result. If we can really create our own token with the token signing key, we should be able to use this token (present or not on the UI) to request datahub. On my side it doesn't work.
I remain available if you need more information! 🙂
Thanks for your time and I hope someone can help me out!astonishing-answer-96712
04/03/2023, 7:59 PMastonishing-answer-96712
04/03/2023, 7:59 PMechoing-airport-49548
04/05/2023, 4:51 PMbusy-mechanic-8014
04/19/2023, 3:41 PMbusy-mechanic-8014
04/19/2023, 4:04 PMcurl --location --request POST 'datahub-gms.datahub.svc.cluster.local:8080/api/graphql' \
--header 'X-DataHub-Actor: urn:li:corpuser:datahub' \
--header 'Content-Type: application/json' \
--data-raw '{ "query":"mutation { createAccessToken(input: { type: PERSONAL, actorUrn: \"urn:li:corpuser:datahub\", duration: ONE_HOUR, name: \"my personal token\" } ) { accessToken metadata { id name description} } }", "variables":{}}'
I also try to use datahub-front endpoint but nothing is happening in the log pods (front & gms).aloof-gpu-11378
04/20/2023, 8:28 PMbulky-soccer-26729
04/20/2023, 8:51 PMbusy-mechanic-8014
04/21/2023, 8:38 AMbusy-mechanic-8014
04/21/2023, 9:05 AMbulky-soccer-26729
04/21/2023, 1:43 PMbusy-mechanic-8014
04/24/2023, 7:20 AM