Skip to content

Commit c282bad

Browse files
authored
Merge pull request #51 from b-long/chore/disable-default-skip-verify
Guard `sdk.WithInsecureSkipVerifyConn()` using `INSECURE_SKIP_VERIFY` env var
2 parents e9ab5c1 + c52314b commit c282bad

13 files changed

+63
-177
lines changed

.github/workflows/build-golang-macos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
4848
# - uses: ./.github/workflows/platform-integration-test.yaml
4949
# with:
50-
# wheel: dist/otdf_python-0.2.13-py3-none-any.whl
50+
# wheel: dist/otdf_python-0.2.14-py3-none-any.whl

.github/workflows/build-golang-ubuntu.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ jobs:
4343
4444
- uses: actions/cache/restore@v4
4545
with:
46-
path: dist/otdf_python-0.2.13-py3-none-any.whl
46+
path: dist/otdf_python-0.2.14-py3-none-any.whl
4747
key: ${{ runner.os }}${{ matrix.python3_version }}-data-${{ github.sha }}
4848

4949
- uses: actions/cache/save@v4
5050
with:
51-
path: dist/otdf_python-0.2.13-py3-none-any.whl
51+
path: dist/otdf_python-0.2.14-py3-none-any.whl
5252
key: ${{ runner.os }}${{ matrix.python3_version }}-data-${{ github.sha }}
5353
restore-keys: |
5454
${{ runner.os }}${{ matrix.python3_version }}-data-
@@ -61,5 +61,5 @@ jobs:
6161
needs: build
6262
uses: ./.github/workflows/platform-integration-test.yaml
6363
with:
64-
wheel: dist/otdf_python-0.2.13-py3-none-any.whl
64+
wheel: dist/otdf_python-0.2.14-py3-none-any.whl
6565
python_version: ${{ matrix.python3_version }}

.github/workflows/platform-integration-test.yaml

Lines changed: 2 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- uses: actions/cache/restore@v4
3131
with:
32-
path: dist/otdf_python-0.2.13-py3-none-any.whl
32+
path: dist/otdf_python-0.2.14-py3-none-any.whl
3333
key: ${{ runner.os }}${{ inputs.python_version }}-data-${{ github.sha }}
3434

3535
- name: Prove that the input file is available
@@ -125,6 +125,7 @@ jobs:
125125
OPENTDF_HOSTNAME: "localhost:8080"
126126
OIDC_TOKEN_ENDPOINT: "http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token"
127127
OPENTDF_KAS_URL: "http://localhost:8080/kas"
128+
INSECURE_SKIP_VERIFY: "TRUE"
128129
run: |
129130
mkdir validation
130131
wheel="$(basename ${{ inputs.wheel }} )"
@@ -136,119 +137,7 @@ jobs:
136137
pip install ./"$wheel"
137138
python validate_otdf_python.py
138139
139-
# - name: Validate the SDK through the command line interface
140-
# run: |
141-
# printf 'here is some data to encrypt' > data
142-
143-
# java -jar target/cmdline.jar \
144-
# --client-id=opentdf-sdk \
145-
# --client-secret=secret \
146-
# --platform-endpoint=localhost:8080 \
147-
# -i \
148-
# encrypt --kas-url=localhost:8080 --mime-type=text/plain --attr https://example.com/attr/attr1/value/value1 --autoconfigure=false -f data -m 'here is some metadata' > test.tdf
149-
150-
# java -jar target/cmdline.jar \
151-
# --client-id=opentdf-sdk \
152-
# --client-secret=secret \
153-
# --platform-endpoint=localhost:8080 \
154-
# -i \
155-
# decrypt -f test.tdf > decrypted
156-
157-
# java -jar target/cmdline.jar \
158-
# --client-id=opentdf-sdk \
159-
# --client-secret=secret \
160-
# --platform-endpoint=localhost:8080 \
161-
# -i \
162-
# metadata -f test.tdf > metadata
163-
164-
# if ! diff -q data decrypted; then
165-
# printf 'decrypted data is incorrect [%s]' "$(< decrypted)"
166-
# exit 1
167-
# fi
168-
169-
# if [ "$(< metadata)" != 'here is some metadata' ]; then
170-
# printf 'metadata is incorrect [%s]\n' "$(< metadata)"
171-
# exit 1
172-
# fi
173-
# working-directory: cmdline
174-
175-
# - name: Encrypt/Decrypt NanoTDF
176-
# run: |
177-
# echo 'here is some data to encrypt' > data
178-
179-
# java -jar target/cmdline.jar \
180-
# --client-id=opentdf-sdk \
181-
# --client-secret=secret \
182-
# --platform-endpoint=localhost:8080 \
183-
# -i \
184-
# encryptnano --kas-url=http://localhost:8080 --attr https://example.com/attr/attr1/value/value1 -f data -m 'here is some metadata' > nano.ntdf
185-
186-
# java -jar target/cmdline.jar \
187-
# --client-id=opentdf-sdk \
188-
# --client-secret=secret \
189-
# --platform-endpoint=localhost:8080 \
190-
# -i \
191-
# decryptnano -f nano.ntdf > decrypted
192-
193-
# if ! diff -q data decrypted; then
194-
# printf 'decrypted data is incorrect [%s]' "$(< decrypted)"
195-
# exit 1
196-
# fi
197-
# working-directory: cmdline
198-
199-
# - uses: JarvusInnovations/background-action@2428e7b970a846423095c79d43f759abf979a635
200-
# name: start another KAS server in background
201-
# with:
202-
# run: >
203-
# <opentdf.yaml >opentdf-beta.yaml yq e '
204-
# (.server.port = 8282)
205-
# | (.mode = ["kas"])
206-
# | (.sdk_config = {"endpoint":"http://localhost:8080","plaintext":true,"client_id":"opentdf","client_secret":"secret"})
207-
# '
208-
# && go run ./service --config-file ./opentdf-beta.yaml start
209-
# wait-on: |
210-
# tcp:localhost:8282
211-
# log-output-if: true
212-
# wait-for: 90s
213-
# working-directory: platform
214-
# - name: Make sure that the second platform is up
215-
# run: |
216-
# grpcurl -plaintext localhost:8282 kas.AccessService/PublicKey
217-
# - name: Validate multikas through the command line interface
218-
# run: |
219-
# printf 'here is some data to encrypt' > data
220-
221-
# java -jar target/cmdline.jar \
222-
# --client-id=opentdf-sdk \
223-
# --client-secret=secret \
224-
# --platform-endpoint=localhost:8080 \
225-
# -i \
226-
# encrypt --kas-url=localhost:8080,localhost:8282 -f data -m 'here is some metadata' > test.tdf
227-
228-
# java -jar target/cmdline.jar \
229-
# --client-id=opentdf-sdk \
230-
# --client-secret=secret \
231-
# --platform-endpoint=localhost:8080 \
232-
# -i \
233-
# decrypt -f test.tdf > decrypted
234-
235-
# java -jar target/cmdline.jar \
236-
# --client-id=opentdf-sdk \
237-
# --client-secret=secret \
238-
# --platform-endpoint=localhost:8080 \
239-
# -i \
240-
# metadata -f test.tdf > metadata
241-
242-
# if ! diff -q data decrypted; then
243-
# printf 'decrypted data is incorrect [%s]' "$(< decrypted)"
244-
# exit 1
245-
# fi
246140
247-
# if [ "$(< metadata)" != 'here is some metadata' ]; then
248-
# printf 'metadata is incorrect [%s]\n' "$(< metadata)"
249-
# exit 1
250-
# fi
251-
# working-directory: cmdline
252141
253142
# platform-xtest:
254143
# permissions:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Install from the [Python Package Index (PyPI)](https://pypi.org):
2727
pip install otdf_python
2828

2929
# Install a pinned version
30-
pip install otdf-python==0.2.13
30+
pip install otdf-python==0.2.14
3131

3232
# Install a pinned version, from test.pypi.org
33-
pip install -i https://test.pypi.org/simple/ otdf-python==0.2.13
33+
pip install -i https://test.pypi.org/simple/ otdf-python==0.2.14
3434
```
3535

3636
## Usage

build-scripts/ci-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ echo "✨✨✨ Build wheel"
7272
poetry run python3 setup.py bdist_wheel
7373

7474
echo "✨✨✨ Install wheel"
75-
pip install dist/otdf_python-0.2.13-py3-none-any.whl
75+
pip install dist/otdf_python-0.2.14-py3-none-any.whl

build-scripts/make_and_validate_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ python3 -m pip install --upgrade setuptools wheel
4747
python3 setup.py bdist_wheel
4848

4949
# Prove that the wheel can be installed
50-
pip install dist/otdf_python-0.2.13-py3-none-any.whl
50+
pip install dist/otdf_python-0.2.14-py3-none-any.whl
5151

5252
if [[ "$SKIP_TESTS" == "-s" || "$SKIP_TESTS" == "--skip-tests" ]]; then
5353
echo "Build is complete, skipping tests."

build-scripts/uv_make_and_validate_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ loud_print "Installing wheel"
7070
uv venv .venv-wheel --python 3.12 "$PY_TYPE"
7171
source "${BUILD_ROOT}/.venv-wheel/bin/activate"
7272
pip install pybindgen
73-
pip install dist/otdf_python-0.2.13-py3-none-any.whl
73+
pip install dist/otdf_python-0.2.14-py3-none-any.whl
7474

7575
if [[ "$SKIP_TESTS" == "-s" || "$SKIP_TESTS" == "--skip-tests" ]]; then
7676
echo "Build is complete, skipping tests."

main.go

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,17 @@ type OpentdfConfig struct {
4242
KasUrl string
4343
}
4444

45-
/*
46-
Based on: https://stackoverflow.com/a/42849112
47-
func inputValidation(normalConfig DecryptionConfig) (*DecryptionConfig, error) {
48-
// Convert our Struct to a Map
49-
var inInterface map[string]interface{}
50-
inrec, _ := json.Marshal(normalConfig)
51-
json.Unmarshal(inrec, &inInterface)
52-
53-
// Iterate through fields in the map and fail if empty value found
54-
for field, val := range inInterface {
55-
if val == nil || val == "" {
56-
// fmt.Println("KV Pair: ", field, val)
57-
return nil, errors.New("Missing configuration value for field " + field)
58-
}
45+
func getEnv(key, defaultValue string) string {
46+
if value, ok := os.LookupEnv(key); ok {
47+
return value
5948
}
60-
61-
return &normalConfig, nil
49+
return defaultValue
6250
}
63-
*/
6451

52+
/*
53+
NOTE: When the environment variable 'INSECURE_SKIP_VERIFY' is set to 'TRUE',
54+
this option for the OpenTDF SDK will be set.
55+
*/
6556
func newSdkClient(config OpentdfConfig, authScopes []string) (*sdk.SDK, error) {
6657
// NOTE: The 'platformEndpoint' is sometimes referenced as 'host'
6758
if strings.Count(config.TokenEndpoint, "http://") == 1 {
@@ -71,16 +62,25 @@ func newSdkClient(config OpentdfConfig, authScopes []string) (*sdk.SDK, error) {
7162
sdk.WithInsecurePlaintextConn(),
7263
)
7364
} else if strings.Count(config.TokenEndpoint, "https://") == 1 {
74-
return sdk.New(config.PlatformEndpoint,
65+
opts := []sdk.Option{
7566
sdk.WithClientCredentials(config.ClientId, config.ClientSecret, authScopes),
7667
sdk.WithTokenEndpoint(config.TokenEndpoint),
77-
sdk.WithInsecureSkipVerifyConn(),
78-
)
68+
}
69+
70+
if getEnv("INSECURE_SKIP_VERIFY", "FALSE") == "TRUE" {
71+
opts = append(opts, sdk.WithInsecureSkipVerifyConn())
72+
}
73+
74+
return sdk.New(config.PlatformEndpoint, opts...)
7975
} else {
8076
return nil, errors.New("invalid TokenEndpoint given")
8177
}
8278
}
8379

80+
/*
81+
NOTE: When the environment variable 'INSECURE_SKIP_VERIFY' is set to 'TRUE',
82+
this option for the OpenTDF SDK will be set.
83+
*/
8484
func peSdkClient(config OpentdfConfig, authScopes []string, token TokenAuth) (*sdk.SDK, error) {
8585
// NOTE: The 'platformEndpoint' is sometimes referenced as 'host'
8686
if strings.Count(config.TokenEndpoint, "http://") == 1 {
@@ -91,12 +91,17 @@ func peSdkClient(config OpentdfConfig, authScopes []string, token TokenAuth) (*s
9191
sdk.WithInsecurePlaintextConn(),
9292
)
9393
} else if strings.Count(config.TokenEndpoint, "https://") == 1 {
94-
return sdk.New(config.PlatformEndpoint,
94+
opts := []sdk.Option{
9595
sdk.WithClientCredentials(config.ClientId, config.ClientSecret, authScopes),
9696
sdk.WithTokenEndpoint(config.TokenEndpoint),
9797
sdk.WithTokenExchange(token.AccessToken, []string{token.NpeClientId}),
98-
sdk.WithInsecureSkipVerifyConn(),
99-
)
98+
}
99+
100+
if getEnv("INSECURE_SKIP_VERIFY", "FALSE") == "TRUE" {
101+
opts = append(opts, sdk.WithInsecureSkipVerifyConn())
102+
}
103+
104+
return sdk.New(config.PlatformEndpoint, opts...)
100105
} else {
101106
return nil, errors.New("invalid TokenEndpoint given")
102107
}

0 commit comments

Comments
 (0)