Skip to content
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

Limit access to bridgehead configuration repository #4

Merged
merged 4 commits into from
Dec 23, 2024

Conversation

timakro
Copy link
Contributor

@timakro timakro commented Dec 20, 2024

This change enforces that secret sync clients can only request project access tokens for the bridgehead configuration repository of the respective site.

This change enforces that secret sync clients can only request project
access tokens for the bridgehead configuration repository of the
respective site.
Comment on lines 27 to 48
/// Derive the bridgehead configuration repository from the beam id of the requester.
/// Example return value: "bridgehead-configurations/bridgehead-config-berlin"
fn derive_bridgehead_config_repo_from_beam_id(requester: &AppId) -> Result<String, String> {
let mut parts = requester.as_ref().splitn(3, '.');
let (_app, proxy, broker) = (parts.next().unwrap(), parts.next().unwrap(), parts.next().unwrap());

let group = match broker {
"broker.ccp-it.dktk.dkfz.de" => "bridgehead-configurations", // ccp
"broker.bbmri.sample.de" => "bbmri-bridgehead-configs", // bbmri
"broker.bbmri.de" => "bbmri-bridgehead-configs", // gbn
"test-no-real-data.broker.samply.de" => "bridgehead-configurations", // cce, itcc, kr
"broker.hector.dkfz.de" => "dhki", // dhki
_ => return Err(format!("Bridgehead configuration repository not known for beam id {requester}")),
};

Ok(match group {
"bridgehead-configurations" => format!("{group}/bridgehead-config-{proxy}"),
"dhki" => format!("{group}/{proxy}-bk"),
_ => format!("{group}/{proxy}"),
})
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@torbrenner I implemented the list you sent me; please confirm this is correct. I found one more irregularity: projects in the bridgehead-configurations group need the bridgehead-config- prefix, whereas projects in the bbmri-bridgehead-configs group don't. I can't check the other groups because I don't have permissions to see them on GitLab.

@timakro timakro requested a review from Threated December 20, 2024 17:59
Comment on lines 33 to 40
let group = match broker {
"broker.ccp-it.dktk.dkfz.de" => "bridgehead-configurations", // ccp
"broker.bbmri.sample.de" => "bbmri-bridgehead-configs", // bbmri
"broker.bbmri.de" => "bbmri-bridgehead-configs", // gbn
"test-no-real-data.broker.samply.de" => "bridgehead-configurations", // cce, itcc, kr
"broker.hector.dkfz.de" => "dhki", // dhki
_ => return Err(format!("Bridgehead configuration repository not known for beam id {requester}")),
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you discussed with Torben and Martin but from my side I think I would have made this a config option instead of deriving it from the broker id but that seems fine as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you imply there is one central secret sync per broker? It would make sense then, yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there pretty much has to be because we have to actively pull tasks from the broker and we really ever poll from one broker. But leave it like that it will be fine

central/src/gitlab.rs Outdated Show resolved Hide resolved
shared/src/lib.rs Outdated Show resolved Hide resolved
@Threated Threated merged commit 6df984b into main Dec 23, 2024
2 checks passed
@Threated Threated deleted the pr-limit-access-to-bridgehead-configuration-repo branch December 23, 2024 08:48
Comment on lines +30 to +31
let mut parts = requester.as_ref().splitn(3, '.');
let (_app, proxy, broker) = (parts.next().unwrap(), parts.next().unwrap(), parts.next().unwrap());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timakro Sorry for being late, but do you have to unwrap? Isn't this available as a function of the AppId?

Copy link
Contributor Author

@timakro timakro Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppId is missing a function to get the broker id. Should I open a PR in the beam repo to add this?

Comment on lines +33 to +46
let group = match broker {
"broker.ccp-it.dktk.dkfz.de" => "bridgehead-configurations", // ccp
"broker.bbmri.sample.de" => "bbmri-bridgehead-configs", // bbmri
"broker.bbmri.de" => "bbmri-bridgehead-configs", // gbn
"test-no-real-data.broker.samply.de" => "bridgehead-configurations", // cce, itcc, kr
"broker.hector.dkfz.de" => "dhki", // dhki
_ => return Err(format!("Bridgehead configuration repository group not known for broker {broker}")),
};

Ok(match group {
"bridgehead-configurations" => format!("{group}/bridgehead-config-{proxy}"),
"dhki" => format!("{group}/{proxy}-bk"),
_ => format!("{group}/{proxy}"),
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future work: Would it be possible to externalize this to e.g. a config file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get rid of the first match we could use Jans idea and make it a config option for the secret sync central component. If I understand correctly, each broker has their own secret sync central component so that should work fine.

For the second match I could add a config option where you can specify an optional prefix for the repository name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants