-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/influxdb non admin token #153
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
# Wait for InfluxDB to start | ||
until curl -s http://{{INFLUXDB_HOSTNAME}}:8086/health | grep -q '"status": "pass"'; do | ||
echo "Waiting for InfluxDB to start..." | ||
sleep 1 | ||
done | ||
|
||
# Get the bucket ID | ||
BUCKET_ID=$(curl -s -X GET http://{{INFLUXDB_HOSTNAME}}:8086/api/v2/buckets -H 'Authorization: Token "{{INFLUXDB_TOKEN}}"' -H "Accept: application/json" | jq -r '.buckets[] | select(.name=="{{DOCKER_INFLUXDB_INIT_BUCKET}}") | .id') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though we create just one bucket, there can be multiple in the influx in the end if created manually by the user. |
||
# Get the org ID | ||
ORG_ID=$(curl -s -X GET http://{{INFLUXDB_HOSTNAME}}:8086/api/v2/orgs -H 'Authorization: Token "{{INFLUXDB_TOKEN}}"' -H "Accept: application/json" | jq -r '.orgs[] | select(.name=="{{DOCKER_INFLUXDB_INIT_ORG}}") | .id') | ||
|
||
# Get the user ID | ||
USER_ID=$(curl -s -X GET http://{{INFLUXDB_HOSTNAME}}:8086/api/v2/users -H 'Authorization: Token "{{INFLUXDB_TOKEN}}"' -H "Accept: application/json" | jq -r '.users[] | select(.name=="{{DOCKER_INFLUXDB_INIT_USERNAME}}") | .id') | ||
|
||
# Create the non-admin token using the InfluxDB API v2 | ||
curl -X POST http://{{INFLUXDB_HOSTNAME}}:8086/api/v2/authorizations \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to get the token itself and send it to vault. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even if you manage to send the token into vault, I don't know how to effectively distribute it. |
||
-H "Authorization: Token {{INFLUXDB_TOKEN}}" \ | ||
-H "Accept: application/json" \ | ||
-H "Content-Type: application/json" \ | ||
-d '{ | ||
"description": "Non-admin user with write access", | ||
"orgID": "'"$ORG_ID"'", | ||
"permissions": [ | ||
{ | ||
"action": "write", | ||
"resource": { | ||
"type": "buckets", | ||
"id": "'"$BUCKET_ID"'" | ||
} | ||
} | ||
], | ||
"status": "active", | ||
"userID": "'"$USER_ID"'" | ||
}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sherpa runs with every UP. so it must be restartable without breaking antyhing or creating bambilion of new tokens.