Skip to content

Commit e492f7e

Browse files
Merge branch 'master' into PER-11752-add-rc-support-ci
2 parents 2a852d5 + bd69bfb commit e492f7e

File tree

8 files changed

+19
-10
lines changed

8 files changed

+19
-10
lines changed

app-tests/docker-compose-app-tests.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ services:
2424
- OPAL_POLICY_REPO_WEBHOOK_PARAMS={"secret_header_name":"x-webhook-token","secret_type":"token","secret_parsing_regex":"(.*)","event_request_key":"gitEvent","push_event_value":"git.push"}
2525
- OPAL_AUTH_PUBLIC_KEY=${OPAL_AUTH_PUBLIC_KEY}
2626
- OPAL_AUTH_PRIVATE_KEY=${OPAL_AUTH_PRIVATE_KEY}
27+
- OPAL_AUTH_PRIVATE_KEY_PASSPHRASE=${OPAL_AUTH_PRIVATE_KEY_PASSPHRASE}
2728
- OPAL_AUTH_MASTER_TOKEN=${OPAL_AUTH_MASTER_TOKEN}
2829
- OPAL_AUTH_JWT_AUDIENCE=https://api.opal.ac/v1/
2930
- OPAL_AUTH_JWT_ISSUER=https://opal.ac/

app-tests/run.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ set -e
33

44
export OPAL_AUTH_PUBLIC_KEY
55
export OPAL_AUTH_PRIVATE_KEY
6+
export OPAL_AUTH_PRIVATE_KEY_PASSPHRASE
67
export OPAL_AUTH_MASTER_TOKEN
78
export OPAL_CLIENT_TOKEN
89
export OPAL_DATA_SOURCE_TOKEN
910

1011
function generate_opal_keys {
1112
echo "- Generating OPAL keys"
1213

13-
ssh-keygen -q -t rsa -b 4096 -m pem -f opal_crypto_key -N ""
14+
OPAL_AUTH_PRIVATE_KEY_PASSPHRASE="123456"
15+
ssh-keygen -q -t rsa -b 4096 -m pem -f opal_crypto_key -N "$OPAL_AUTH_PRIVATE_KEY_PASSPHRASE"
1416
OPAL_AUTH_PUBLIC_KEY="$(cat opal_crypto_key.pub)"
1517
OPAL_AUTH_PRIVATE_KEY="$(tr '\n' '_' < opal_crypto_key)"
1618
rm opal_crypto_key.pub opal_crypto_key

docker/docker-compose-with-security.yml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ services:
3939
# private key (used for signing on new JWT tokens).
4040
- OPAL_AUTH_PUBLIC_KEY=${OPAL_AUTH_PUBLIC_KEY}
4141
- OPAL_AUTH_PRIVATE_KEY=${OPAL_AUTH_PRIVATE_KEY}
42+
- OPAL_AUTH_PRIVATE_KEY_PASSPHRASE=${OPAL_AUTH_PRIVATE_KEY_PASSPHRASE}
4243
# the master token is used in only one scenario - when we want to generate a new JWT token.
4344
# the /token api endpoint on the OPAL server is the only endpoint that requires the master token.
4445
- OPAL_AUTH_MASTER_TOKEN=${OPAL_AUTH_MASTER_TOKEN}

docker/run-example-with-security.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ echo "keys and run OPAL in *secure mode*."
2222
echo "------------------------------------------------------------------"
2323

2424
echo "generating opal crypto keys..."
25-
ssh-keygen -q -t rsa -b 4096 -m pem -f opal_crypto_key -N ""
25+
export OPAL_AUTH_PRIVATE_KEY_PASSPHRASE="123456"
26+
ssh-keygen -q -t rsa -b 4096 -m pem -f opal_crypto_key -N "$OPAL_AUTH_PRIVATE_KEY_PASSPHRASE"
2627

2728
echo "saving crypto keys to env vars and removing temp key files..."
2829
export OPAL_AUTH_PUBLIC_KEY=`cat opal_crypto_key.pub`

packages/opal-client/opal_client/data/api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def _handle_policy_data_update(span=None):
2727
)
2828
return {"status": "ok"}
2929
else:
30-
if span:
30+
if span is not None:
3131
span.set_status(trace.StatusCode.ERROR)
3232
span.set_attribute("error", True)
3333
span.set_attribute("error_type", "updater_disabled")
@@ -37,7 +37,7 @@ async def _handle_policy_data_update(span=None):
3737
)
3838
except Exception as e:
3939
logger.error(f"Error during data update: {str(e)}")
40-
if span:
40+
if span is not None:
4141
span.set_status(trace.StatusCode.ERROR)
4242
span.set_attribute("error", True)
4343
span.record_exception(e)

packages/opal-client/opal_client/policy/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def _handle_policy_update(span=None):
2121
return {"status": "ok"}
2222
except Exception as e:
2323
logger.error(f"Error during policy update: {str(e)}")
24-
if span:
24+
if span is not None:
2525
span.set_status(trace.StatusCode.ERROR)
2626
span.set_attribute("error", True)
2727
span.record_exception(e)

packages/opal-server/opal_server/policy/watcher/task.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ async def trigger(self, topic: Topic, data: Any):
126126
pull)"""
127127
try:
128128
async with start_span("opal_server_policy_update") as span:
129-
span.set_attribute("topic", str(topic))
129+
if span is not None:
130+
span.set_attribute("topic", str(topic))
130131
await self._watcher.check_for_changes()
131132
except Exception as e:
132133
raise

packages/opal-server/opal_server/scopes/api.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ async def put_scope(
125125
claims: JWTClaims = Depends(authenticator),
126126
):
127127
async with start_span("opal_server_policy_update") as span:
128-
span.set_attribute("scope_id", scope_in.scope_id)
128+
if span is not None:
129+
span.set_attribute("scope_id", scope_in.scope_id)
129130
return await _handle_put_scope(force_fetch, scope_in, claims)
130131

131132
async def _handle_put_scope(
@@ -273,7 +274,8 @@ async def get_scope_policy(
273274
),
274275
):
275276
async with start_span("opal_server_policy_bundle_request") as span:
276-
span.set_attribute("scope_id", scope_id)
277+
if span is not None:
278+
span.set_attribute("scope_id", scope_id)
277279
policy_bundle = await _handle_get_scope_policy(scope_id, base_hash)
278280
policy_bundle_size_histogram = get_policy_bundle_size_histogram()
279281
if policy_bundle_size_histogram and policy_bundle.bundle:
@@ -380,7 +382,8 @@ async def publish_data_update_event(
380382
scope_id: str = Path(..., description="Scope ID"),
381383
):
382384
async with start_span("opal_server_data_update") as span:
383-
span.set_attribute("scope_id", scope_id)
385+
if span is not None:
386+
span.set_attribute("scope_id", scope_id)
384387
await _handle_publish_data_update_event(update, claims, scope_id, span)
385388

386389
async def _handle_publish_data_update_event(
@@ -399,7 +402,7 @@ async def _handle_publish_data_update_event(
399402
entry.topics = [f"data:{topic}" for topic in entry.topics]
400403
all_topics.update(entry.topics)
401404

402-
if span:
405+
if span is not None:
403406
span.set_attribute("entries_count", len(update.entries))
404407
span.set_attribute("topics", list(all_topics))
405408

0 commit comments

Comments
 (0)