-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: rewrite in pure Python #62
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
Changes from all commits
3c309f6
bddba91
fcf723e
b4df15d
4dddd0e
098ba22
f789166
4d586a3
bc705ec
9269a9e
2a3841c
e38526c
762a939
bb9d16b
8df1854
d6f19f0
5f63636
0384137
01b3b9d
912ff4a
8b4a535
0669650
e6a83d3
c792967
fa796e5
a822bc6
e381632
78d760d
eb14223
adfdbdd
30a6375
8d06656
336d169
9ecee9e
6976cbb
a96a138
2d48aea
6361b22
3cc1ebc
cc47a52
66e04e1
e820de7
781c8c0
01b8169
1dc83a8
f2e28ba
fbc5529
791b6c9
5d132c1
b66294e
ed87839
155121f
468db62
dc56ef0
58f5558
02f51cd
d2a0347
3448670
8cdc401
04a650c
4c4119e
20e986c
ca7903d
8f642ae
78d583f
0736b3e
cf31aed
be91b69
6f01c1e
30b032b
84cf5c1
ace14e7
9891ea8
5ed358b
9cd6d44
a4c6cb0
652e742
0cc0959
dbc9f80
3bb4283
de00583
ce8a520
5f3b907
8e5b86f
ee6452e
af69a88
cca9e3e
35d06e3
f61b020
c699d02
0e09171
c1395b1
e24a665
56117b4
6a1d57b
0cc49f9
e5b4efd
238715f
13be279
57d723d
fe1ee2d
6cfaee6
9f2d2ed
085f056
646345c
11497fb
63ef99a
6cb25d8
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,6 @@ | ||
| OPENTDF_PLATFORM_HOST="localhost" | ||
| OPENTDF_PLATFORM_PORT=8080 | ||
| OPENTDF_PLATFORM_URL="http://localhost:8080" | ||
|
|
||
| KEYCLOAK_URL="http://localhost:8888/auth" | ||
| OIDC_OP_TOKEN_ENDPOINT="http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token" |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||||||||||
| #!/bin/bash | ||||||||||||||
|
|
||||||||||||||
| # Derive additional environment variables | ||||||||||||||
| TOKEN_URL="${OIDC_OP_TOKEN_ENDPOINT}" | ||||||||||||||
| OTDF_HOST_AND_PORT="${OPENTDF_PLATFORM_HOST}" | ||||||||||||||
| OTDF_CLIENT="${OPENTDF_CLIENT_ID}" | ||||||||||||||
| OTDF_CLIENT_SECRET="${OPENTDF_CLIENT_SECRET}" | ||||||||||||||
|
|
||||||||||||||
| echo "🔧 Environment Configuration:" | ||||||||||||||
| echo " TOKEN_URL: ${TOKEN_URL}" | ||||||||||||||
| echo " OTDF_HOST_AND_PORT: ${OTDF_HOST_AND_PORT}" | ||||||||||||||
| echo " OTDF_CLIENT: ${OTDF_CLIENT}" | ||||||||||||||
| echo " OTDF_CLIENT_SECRET: ${OTDF_CLIENT_SECRET}" | ||||||||||||||
|
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. Printing secrets like
Suggested change
|
||||||||||||||
| echo "" | ||||||||||||||
|
|
||||||||||||||
| get_token() { | ||||||||||||||
| curl -k --location "$TOKEN_URL" \ | ||||||||||||||
|
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. Using 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. The use of |
||||||||||||||
| --header "X-VirtruPubKey;" \ | ||||||||||||||
| --header "Content-Type: application/x-www-form-urlencoded" \ | ||||||||||||||
| --data-urlencode "grant_type=client_credentials" \ | ||||||||||||||
| --data-urlencode "client_id=$OTDF_CLIENT" \ | ||||||||||||||
| --data-urlencode "client_secret=$OTDF_CLIENT_SECRET" | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| echo "🔐 Getting access token..." | ||||||||||||||
| BEARER=$( get_token | jq -r '.access_token' ) | ||||||||||||||
|
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. It's good practice to check if the
Suggested change
|
||||||||||||||
| # NOTE: It's always okay to print this token, because it will | ||||||||||||||
| # only be valid / available in dummy / dev scenarios | ||||||||||||||
| [[ "${DEBUG:-}" == "1" ]] && echo "Got Access Token: ${BEARER}" | ||||||||||||||
|
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. |
||||||||||||||
| echo "" | ||||||||||||||
|
|
||||||||||||||
| # Array of usernames to check | ||||||||||||||
| USERNAMES=("opentdf" "sample-user" "sample-user-1" "cli-client" "opentdf-sdk") | ||||||||||||||
|
|
||||||||||||||
| for USERNAME in "${USERNAMES[@]}"; do | ||||||||||||||
| echo "👤 Fetching entitlements for username: ${USERNAME}" | ||||||||||||||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||||||||||||||
|
|
||||||||||||||
| grpcurl -plaintext \ | ||||||||||||||
| -H "authorization: Bearer $BEARER" \ | ||||||||||||||
| -d "{ | ||||||||||||||
| \"entities\": [ | ||||||||||||||
| { | ||||||||||||||
| \"userName\": \"$USERNAME\" | ||||||||||||||
| } | ||||||||||||||
| ] | ||||||||||||||
| }" \ | ||||||||||||||
| "$OTDF_HOST_AND_PORT" \ | ||||||||||||||
| authorization.AuthorizationService/GetEntitlements | ||||||||||||||
|
|
||||||||||||||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||||||||||||||
| echo "✅ Entitlements retrieval complete for ${USERNAME}!" | ||||||||||||||
| echo "" | ||||||||||||||
| done | ||||||||||||||
|
|
||||||||||||||
| echo "🎉 All entitlement checks completed!" | ||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||
|
|
||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||
|
|
||||||||||||||||||
| if ! [ -d platform ]; then | ||||||||||||||||||
| git clone https://github.com/opentdf/platform.git | ||||||||||||||||||
| fi | ||||||||||||||||||
| cd platform | ||||||||||||||||||
| git checkout 3360befcb3e6e9791d7bfd2e89128aee0e7d2818 # Branch 'DSPX-1539-keytoolnomore' | ||||||||||||||||||
|
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. |
||||||||||||||||||
|
|
||||||||||||||||||
| yq -i '.realms[0].clients[0].client.directAccessGrantsEnabled = true | .realms[0].clients[0].client.serviceAccountsEnabled = true' service/cmd/keycloak_data.yaml | ||||||||||||||||||
|
|
||||||||||||||||||
| yq -i '.realms[0].clients[1].client.directAccessGrantsEnabled = true | .realms[0].clients[1].client.serviceAccountsEnabled = true' service/cmd/keycloak_data.yaml | ||||||||||||||||||
|
|
||||||||||||||||||
| yq -i '.realms[0].clients[4].client.directAccessGrantsEnabled = true | .realms[0].clients[4].client.serviceAccountsEnabled = true' service/cmd/keycloak_data.yaml | ||||||||||||||||||
|
Comment on lines
+11
to
+15
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. These
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| if ! [ -d ./keys ]; then | ||||||||||||||||||
| go mod download | ||||||||||||||||||
|
|
||||||||||||||||||
| go mod verify | ||||||||||||||||||
|
|
||||||||||||||||||
| .github/scripts/init-temp-keys.sh | ||||||||||||||||||
| cp opentdf-example.yaml opentdf.yaml | ||||||||||||||||||
|
|
||||||||||||||||||
| # Edit 'opentdf.yaml' for our use case | ||||||||||||||||||
| yq -i 'del(.db) | .services.entityresolution.url = "http://localhost:8888/auth" | .server.auth.issuer = "http://localhost:8888/auth/realms/opentdf"' opentdf.yaml | ||||||||||||||||||
| # The above expression can also be written as 3 separate commands: | ||||||||||||||||||
| # yq -i 'del(.db)' opentdf.yaml | ||||||||||||||||||
| # yq -i '.services.entityresolution.url = "http://localhost:8888/auth"' opentdf.yaml | ||||||||||||||||||
| # yq -i '.server.auth.issuer = "http://localhost:8888/auth/realms/opentdf"' opentdf.yaml | ||||||||||||||||||
|
|
||||||||||||||||||
| yq -i ' | ||||||||||||||||||
| .server.cryptoProvider = { | ||||||||||||||||||
| "type": "standard", | ||||||||||||||||||
| "standard": { | ||||||||||||||||||
| "keys": [ | ||||||||||||||||||
| { | ||||||||||||||||||
| "kid": "r1", | ||||||||||||||||||
| "alg": "rsa:2048", | ||||||||||||||||||
| "private": "kas-private.pem", | ||||||||||||||||||
| "cert": "kas-cert.pem" | ||||||||||||||||||
| }, | ||||||||||||||||||
| { | ||||||||||||||||||
| "kid": "e1", | ||||||||||||||||||
| "alg": "ec:secp256r1", | ||||||||||||||||||
| "private": "kas-ec-private.pem", | ||||||||||||||||||
| "cert": "kas-ec-cert.pem" | ||||||||||||||||||
| } | ||||||||||||||||||
| ] | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| ' opentdf.yaml | ||||||||||||||||||
| chmod -R 700 ./keys | ||||||||||||||||||
|
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. The permission find ./keys -type d -exec chmod 700 {} +;
find ./keys -type f -exec chmod 600 {} +; |
||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| docker compose up -d --wait --wait-timeout 360 | ||||||||||||||||||
|
|
||||||||||||||||||
| go run ./service provision keycloak | ||||||||||||||||||
|
|
||||||||||||||||||
| go run ./service provision fixtures | ||||||||||||||||||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,42 @@ | ||
| --- | ||
| name: Build Python package(s) | ||
|
|
||
| # Build otdf-python wheel using uv and output the wheel path for downstream workflows | ||
| name: "Build Python Wheel" | ||
| on: | ||
| push: | ||
| branches: | ||
| - disabled | ||
| push: | ||
| branches: | ||
| - chore/rewrite | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-22.04 | ||
| strategy: | ||
| matrix: | ||
| go-version: [1.24.x] | ||
| build: | ||
| runs-on: ubuntu-22.04 | ||
| outputs: | ||
| wheel: ${{ steps.find_wheel.outputs.wheel_path }} | ||
| steps: | ||
| - name: Checkout this repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| # - name: Setup Go | ||
| # uses: actions/setup-go@v4 | ||
| # with: | ||
| # go-version: ${{ matrix.go-version }} | ||
| # cache-dependency-path: go.sum | ||
| # - name: Install dependencies | ||
| # run: go get . | ||
| # - name: Test with Go | ||
| # run: go test -timeout 40s -run ^TestHello$ gotdf_python -count=1 # go test | ||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| enable-cache: true | ||
| cache-dependency-glob: "uv.lock" | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.12' | ||
| - name: Install dependencies | ||
| run: | | ||
| pip install poetry | ||
| - name: Invoke pylint with all dependencies | ||
| run: | | ||
| # Since we don't have our wheel build / install configured yet we use '--no-root' | ||
| poetry install --no-root | ||
| - name: Build otdf-python wheel using uv | ||
| run: | | ||
| uv sync --frozen | ||
| uv build | ||
| shell: bash | ||
|
|
||
| # poetry install | ||
| - name: Find built wheel | ||
| id: find_wheel | ||
| run: | | ||
| wheel_path=$(ls dist/*.whl | head -n1) | ||
| echo "wheel_path=$wheel_path" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
|
|
||
| # Bring this back later | ||
| # poetry run pytest tests/ | ||
| # - name: Upload wheel as artifact | ||
| # uses: actions/upload-artifact@v4 | ||
| # with: | ||
| # name: python-wheel | ||
| # path: dist/*.whl | ||
| # overwrite: true |
This file was deleted.
This file was deleted.
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.
For improved robustness, it's a good practice to add
set -euo pipefailat the beginning of your shell scripts. This will cause the script to exit immediately if a command fails, preventing unexpected behavior.