Repository navigation
fix(api): let SSO accounts log in over SFTP #1086
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
Merged
+90
−7
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
67b6ba9
fix(api): log why an SFTP login was refused
claude 06a633f
fix(api): let SSO accounts named by email log in over SFTP
claude 0ffdcb1
docs(changelog): SFTP login for SSO accounts
claude 3e60030
chore: bump sftp so a refused SSH key falls back to the password (sft…
claude a48fa78
docs(changelog): note the SSH key fallback
claude 62b4a60
docs: correct the sftp login actor comment for long SSO names
claude 8e6f607
fix(api): key the sftp username budget on the full name; document the…
claude 80ecd9b
fix(api): bound the sftp username budget key
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package handlers | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| // An SSO account is named by its email address. Such a user can log in over SFTP with that name. | ||
| func TestSFTPLogin_SSOEmailUsername(t *testing.T) { | ||
| env := newSFTPLoginEnv(t) | ||
| h := sftpLoginRouter(env) | ||
| const name = "valgul.sso@example.com" | ||
| if _, err := env.store.DB.ExecContext(t.Context(), | ||
| `INSERT INTO users(username, display_name, email, role, pw_hash) VALUES (?, ?, ?, ?, ?)`, | ||
| name, "valgul", name, "viewer", "x"); err != nil { | ||
| t.Fatalf("insert sso user: %v", err) | ||
| } | ||
| uid := userIDOf(t, env, name) | ||
| pw, err := env.sessions.GenerateAndStoreSFTPPassword(t.Context(), uid, 24) | ||
| if err != nil { | ||
| t.Fatalf("set sftp password: %v", err) | ||
| } | ||
| if rr := env.login(t, h, map[string]any{"username": name, "password": pw}); rr.Code != http.StatusOK { | ||
| t.Fatalf("login as %s: status %d body %s", name, rr.Code, rr.Body.String()) | ||
| } | ||
| } | ||
|
|
||
| func TestValidSFTPUsername(t *testing.T) { | ||
| for name, want := range map[string]bool{ | ||
| "alice": true, | ||
| "valgul.sso@example.com": true, | ||
| "": false, | ||
| "has space": false, | ||
| "tab\tname": false, | ||
| "ctrl\x01": false, | ||
| "a/b": false, | ||
| "\xff": false, | ||
| strings.Repeat("a", sftpUsernameMaxRunes): true, | ||
| strings.Repeat("a", sftpUsernameMaxRunes+1): false, | ||
| } { | ||
| if got := validSFTPUsername(name); got != want { | ||
| t.Errorf("validSFTPUsername(%q) = %v, want %v", name, got, want) | ||
| } | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # SFTP login works for SSO accounts | ||
|
|
||
| Accounts created through SSO are named by their email address, and the SFTP login refused every such name before checking the password or key. They can now log in with their panel username, for example `sftp -P 2222 alice@example.com@sftp.example.com`. An SSH key that is not registered no longer drops the connection: the client falls back to the password prompt. The API log now names the cause of each refused SFTP login, for operators. [PR #1086](https://github.com/GameplanePanel/Gameplane/pull/1086) |
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
Submodule sftp
updated
3 files
| +76 −0 | internal/sshserver/key_fallback_test.go | |
| +46 −27 | internal/sshserver/server.go | |
| +1 −1 | specs.md |
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.
Uh oh!
There was an error while loading. Please reload this page.