fix(sshPolicy): parse gateway-qualified roles in the Forseti contract#45
Merged
Conversation
The shipped SSH Forseti contract used Role.Split(':', 2, …) to extract the
SSH username, which silently fails for gateway-qualified roles. For
Role = "ssh:Tide-GW:My Server:demo" the split gave userRole =
"Tide-GW:My Server:demo" — so ValidateData would always deny with
"Not allowed to log in as <whoever>" because the SSH challenge username
could never equal that.
Take everything after the LAST ':' instead. Works for both legacy
short-form "ssh:<user>" and current "ssh:<gw>:<srv>:<user>" roles.
The contract source is uploaded to the ORK at policy commit time, so
this patch takes effect on the next policy commit (no ORK redeploy needed).
…storage.ts The same Forseti SSH contract source is embedded in server/storage.ts. Apply the same gateway-qualified role-parser fix there so the two copies stay in sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Forseti contract source shipped in `client/src/lib/sshPolicy.ts` (`SSH_FORSETI_CONTRACT`) used `Role.Split(':', 2, …)` to extract the SSH username from the policy's `Role` parameter. With `max=2`, only the first colon is consumed:
So `ValidateData` would compare the SSH challenge's `Username` against `"Tide-GW:My Server:demo"` and always deny with `"Not allowed to log in as "`.
This is the actual reason Sign #2 was failing post-fix — not a signature issue (PRs #40–#44 fixed those) but a contract-level mismatch surfaced only once the byte path was correct.
Change
Extract everything after the last `:` in `Role`:
```csharp
var lastColon = Role.LastIndexOf(':');
if (lastColon < 0 || lastColon == Role.Length - 1)
return PolicyDecision.Deny("Role must end with ':'.");
var userRole = Role.Substring(lastColon + 1).Trim();
```
Works for both formats:
Deploy notes
The contract source is uploaded to the ORK at policy commit time. After this lands:
Test plan