Skip to content

Commit ba05852

Browse files
committed
updating lib usage after py-spiffe update
1 parent 25a45db commit ba05852

10 files changed

+27
-20
lines changed

.github/workflows/build-container-prep-image.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
contents: read
1313
steps:
1414
- uses: actions/checkout@v4
15+
with:
16+
lfs: 'true'
1517

1618
- name: Build image
17-
run: docker build . -f ./client/container_preparation/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
19+
run: git lfs pull ; docker build . -f ./client/container_preparation/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
1820

1921
- name: Log in to registry
2022
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

.github/workflows/build-data-prep-image.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
contents: read
1313
steps:
1414
- uses: actions/checkout@v4
15+
with:
16+
lfs: 'true'
1517

1618
- name: Build image
17-
run: docker build . -f ./client/data_preparation/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
19+
run: git lfs pull ; docker build . -f ./client/data_preparation/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
1820

1921
- name: Log in to registry
2022
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

.github/workflows/build-job-prep-image.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
contents: read
1313
steps:
1414
- uses: actions/checkout@v4
15+
with:
16+
lfs: 'true'
1517

1618
- name: Build image
17-
run: docker build . -f ./client/job_preparation/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
19+
run: git lfs pull ; docker build . -f ./client/job_preparation/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
1820

1921
- name: Log in to registry
2022
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

.github/workflows/build-server-image.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
contents: read
1313
steps:
1414
- uses: actions/checkout@v4
15+
with:
16+
lfs: 'true'
1517

1618
- name: Build image
17-
run: docker build . -f ./server/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
19+
run: git lfs pull ; docker build . -f ./server/Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
1820

1921
- name: Log in to registry
2022
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

client/job_preparation/prepare_job.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
ssh_copy_file(ssh_client, sbatch_path, f"~/")
5454

5555
# Copy config file to supercomputer
56-
ssh_copy_file(ssh_client, options.config, f"~/.config/hpcs.conf")
56+
ssh_copy_file(ssh_client, options.config, f"~/.config/hpcs-client.conf")
5757

5858
# Create public encryption key for output data
5959
ident = x25519.Identity.generate()
@@ -63,7 +63,7 @@
6363
public_key_file.write(str(ident.to_public()))
6464

6565
# Write private key to current directory
66-
with open("./private_key", "w+") as private_key_file:
66+
with open("/tmp/private_key", "w+") as private_key_file:
6767
private_key_file.write(str(ident))
6868

6969
# Copy public key to supercomputer

server/app.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
if configuration['spire-server'].get('pre-command') :
3232
spire_interactions.pre_command = configuration['spire-server']['pre-command']
33+
if configuration['spire-server']['pre-command'] == "\"\"":
34+
spire_interactions.pre_command = ""
3335

3436
# Defining the trust domain (SPIRE Trust Domain)
3537
trust_domain = configuration['spire-server']['trust-domain']
@@ -49,7 +51,7 @@ async def handle_dummy_token_endpoint():
4951
if hostname != None:
5052

5153
# Create spiffeID based on the hostname
52-
spiffeID = SpiffeId.parse(f"spiffe://{trust_domain}/h/{hostname}")
54+
spiffeID = SpiffeId(f"spiffe://{trust_domain}/h/{hostname}")
5355

5456
# Associate a token to the spiffeID
5557
result = token_generate(spiffeID)
@@ -87,7 +89,7 @@ async def handle_client_registration():
8789
write_client_policy(hvac_client, f"client_{client_id}")
8890

8991
# Create spiffeID out of this client id
90-
agent_spiffeID = SpiffeId.parse(f"spiffe://{trust_domain}/c/{client_id}")
92+
agent_spiffeID = SpiffeId(f"spiffe://{trust_domain}/c/{client_id}")
9193

9294
# Generate a token to register the agent (again, based on the client id)
9395
result = token_generate(agent_spiffeID)
@@ -99,7 +101,7 @@ async def handle_client_registration():
99101

100102
# Create a spiffeID for the workloads on the client.
101103
# Register workloads that have to run on this agent
102-
workload_spiffeID = SpiffeId.parse(
104+
workload_spiffeID = SpiffeId(
103105
f"spiffe://{trust_domain}/c/{client_id}/workload"
104106
)
105107

@@ -163,7 +165,7 @@ async def handle_workload_creation():
163165
client_id = hashlib.sha256(client_id.encode()).hexdigest()[0:9]
164166

165167
# Parse the spiffeID that will access the application
166-
spiffeID = SpiffeId.parse(
168+
spiffeID = SpiffeId(
167169
f"spiffe://{trust_domain}/c/{client_id}/s/{data['secret']}"
168170
)
169171

@@ -179,7 +181,7 @@ async def handle_workload_creation():
179181
groups_added = []
180182

181183
# Compute node's agent spiffeID
182-
parentID = SpiffeId.parse(f"spiffe://{trust_domain}/h/{compute_node}")
184+
parentID = SpiffeId(f"spiffe://{trust_domain}/h/{compute_node}")
183185

184186
# For each user
185187
if data["users"] != None:

server/lib/spire_interactions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def get_server_identity_JWT() -> JwtSvid:
6464
"""
6565

6666
# Perform an api fetch using pyspiffe
67-
SVID = jwt_workload_api.get_jwt_svid(
67+
SVID = jwt_workload_api.fetch_svid(
6868
audiences=["TESTING"],
69-
subject=SpiffeId().parse("spiffe://lumi-sd-dev/lumi-sd-server"),
69+
subject=SpiffeId("spiffe://lumi-sd-dev/lumi-sd-server"),
7070
)
7171
return SVID
7272

utils/agent-on-the-fly.conf

-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ plugins {
2828
discover_workload_path = true
2929
}
3030
}
31-
32-
WorkloadAttestor "systemd" {
33-
}
3431

3532
WorkloadAttestor "docker" {
3633
plugin_data {}

utils/ship_a_key.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def validate_options(options: argparse.ArgumentParser):
166166

167167
# Check that user provided spiffeID is well formed
168168
try:
169-
spiffeID = spiffe_id.SpiffeId().parse(f"{options.spiffeid}")
169+
spiffeID = spiffe_id.SpiffeId(f"{options.spiffeid}")
170170
except SpiffeIdError:
171171
print(f"Error, spiffeID {options.spiffeid} is malformed")
172172
exit(1)
@@ -268,7 +268,7 @@ def create_authorized_workloads(
268268
)
269269

270270
# Get the client's certificate to perform mTLS
271-
SVID = jwt_workload_api.get_jwt_svid(audiences=["TESTING"], subject=spiffeID)
271+
SVID = jwt_workload_api.fetch_svid(audiences=["TESTING"], subject=spiffeID)
272272

273273
# Perform workloads authorization for the secret to be created
274274
users_spiffeID, client_id, secrets_path, user_role = create_authorized_workloads(

utils/ssh_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def ssh_connect(username: str) -> SSHClient:
3535
host,
3636
port,
3737
username=username,
38-
pkey=pkey,
39-
look_for_keys=False,
38+
pkey=pkey,
39+
look_for_keys=False,
4040
auth_timeout=30,
4141
timeout=30,
4242
)

0 commit comments

Comments
 (0)