Skip to content

Commit

Permalink
Authenticating to external collector with OIDC (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonb authored Nov 27, 2023
1 parent 9e8a2bd commit 7559301
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 8 additions & 6 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
extensions:
basicauth/client:
client_auth:
username: "${env:OTLP_USERNAME}"
password: "${env:OTLP_PASSWORD}"
oauth2client:
client_id: "${env:OIDC_CLIENT_ID}"
client_secret: "${env:OIDC_CLIENT_SECRET}"
token_url: "${env:OIDC_TOKEN_URL}"
scopes: [ "observability" ]
timeout: 10s

receivers:
otlp:
Expand Down Expand Up @@ -49,10 +51,10 @@ exporters:
otlp:
endpoint: "${env:OTLP_HOSTNAME}:${env:OTLP_PORT}"
auth:
authenticator: basicauth/client
authenticator: oauth2client

service:
extensions: [basicauth/client]
extensions: [oauth2client]
pipelines:
traces:
receivers: [otlp]
Expand Down
12 changes: 7 additions & 5 deletions voripos-otel-collector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# This is needed to locate the otelcol-contrib executable
export PATH="/opt/homebrew/bin:$PATH"

OIDC_CLIENT_ID=$(defaults read com.vori.VoriPOS provisioned_oidcClientID)
OIDC_CLIENT_SECRET=$(defaults read com.vori.VoriPOS provisioned_oidcClientSecret)
OIDC_TOKEN_URL=$(defaults read com.vori.VoriPOS provisioned_oidcTokenUrl)
OTLP_HOSTNAME=$(defaults read com.vori.VoriPOS provisioned_otlpHostname)
OTLP_PORT=$(defaults read com.vori.VoriPOS provisioned_otlpPort)
OTLP_USERNAME=$(defaults read com.vori.VoriPOS provisioned_otlpUsername)
OTLP_PASSWORD=$(defaults read com.vori.VoriPOS provisioned_otlpPassword)
VORIPOS_ENVIRONMENT=$(defaults read com.vori.VoriPOS provisioned_environment)
VORIPOS_BANNER_ID=$(defaults read com.vori.VoriPOS provisioned_bannerID)
VORIPOS_BANNER_NAME=$(defaults read com.vori.VoriPOS provisioned_bannerName)
Expand All @@ -15,18 +16,19 @@ VORIPOS_STORE_NAME=$(defaults read com.vori.VoriPOS provisioned_storeName)
VORIPOS_LANE_ID=$(defaults read com.vori.VoriPOS provisioned_laneID)
VORIPOS_LANE_NAME=$(defaults read com.vori.VoriPOS provisioned_laneName)

export OIDC_CLIENT_ID
export OIDC_CLIENT_SECRET
export OIDC_TOKEN_URL
export OTLP_HOSTNAME
export OTLP_PORT
export OTLP_USERNAME
export OTLP_PASSWORD
export VORIPOS_ENVIRONMENT
export VORIPOS_BANNER_ID
export VORIPOS_BANNER_NAME
export VORIPOS_STORE_ID
export VORIPOS_STORE_NAME
export VORIPOS_LANE_ID
export VORIPOS_LANE_NAME
export VORIPOS_OTEL_COLLECTOR_VERSION=0.1.0
export VORIPOS_OTEL_COLLECTOR_VERSION=0.2.0

echo "Data will be exported to ${OTLP_HOSTNAME}:${OTLP_PORT}"
otelcol-contrib --config=file:$( dirname -- "$0"; )/config.yml

0 comments on commit 7559301

Please sign in to comment.