Commit b9e2ca2
feat: SSH user mapping modes for server-type edges (#92)
* feat: SSH user mapping modes for server-type edges (inherited/provided/identity)
Add spec.server.sshUserMapping field with three modes:
- inherited (default): username+key from agent-reported Edge.Status.SSHCredentials
- provided: username+key from admin-configured spec.server.sshCredentialsRef Secret
- identity: username from caller kcp/OIDC identity; key from sshCredentialsRef
## API changes
- New type SSHUserMappingMode (string) with constants:
- SSHUserMappingInherited = "inherited"
- SSHUserMappingProvided = "provided"
- SSHUserMappingIdentity = "identity"
- ServerEdgeSpec.SSHUserMapping field (default: inherited)
- ServerEdgeSpec.SSHCredentialsRef field (*corev1.SecretReference)
- Regenerated CRDs via make codegen
## Hub changes (pkg/virtual/builder/edges_proxy_builder.go)
- resolveCallerIdentity(): kcp TokenReview to extract caller username (best-effort)
- edgesSSHHandler: accepts callerIdentity, passes to fetchSSHCredentials
- fetchSSHCredentials: branches on SSHUserMapping mode
- readStatusSSHCreds(): extracted helper for inherited/fallback path
- readSSHCredsFromSecret(): new helper reads username+key from a Secret
(usernameOverride non-empty overrides the Secret's username field)
## Test infrastructure changes
- TestSSHServer: added AddUser()/AddAnyUserKey() for configurable auth,
ConnectedUsers() for test assertions, USER env var in spawned commands
- ServerProcess: added SSHUser/SSHPassword fields; SSHServer is now public
and can be pre-configured before Start()
- New framework helpers: GenerateTestSSHKeypair, IndentLines,
ResolveCallerIdentity, context helpers for key/identity
## New e2e tests
- SSHUserMappingInherited: agent reports testuser, verified via echo $USER
- SSHUserMappingProvided: hub reads username+key from sshCredentialsRef Secret
- SSHUserMappingIdentity: hub uses TokenReview caller identity as SSH username
Closes #53
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
* fix: add --ssh-user/--ssh-password/--ssh-private-key flags to 'kedge agent join' CLI
The e2e tests invoke the agent via the 'kedge agent join' subcommand, not the
standalone kedge-agent binary. The SSH credential flags (--ssh-user,
--ssh-password, --ssh-private-key) were added to cmd/kedge-agent/main.go but
were not propagated to pkg/cli/cmd/agent.go, causing TestSSHUserMappingInherited
to fail with 'Error: unknown flag: --ssh-user'.
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
---------
Co-authored-by: OpenClaw Bot <bot@openclaw.ai>
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>1 parent d4ea891 commit b9e2ca2
13 files changed
Lines changed: 934 additions & 47 deletions
File tree
- apis/kedge/v1alpha1
- config
- crds
- kcp
- pkg
- cli/cmd
- hub/bootstrap/crds
- virtual/builder
- test/e2e
- cases
- framework
- suites/ssh
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
34 | 46 | | |
35 | 47 | | |
36 | 48 | | |
| |||
118 | 130 | | |
119 | 131 | | |
120 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
121 | 148 | | |
122 | 149 | | |
123 | 150 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| |||
96 | 112 | | |
97 | 113 | | |
98 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
99 | 127 | | |
100 | 128 | | |
101 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
75 | 91 | | |
76 | 92 | | |
77 | 93 | | |
| |||
92 | 108 | | |
93 | 109 | | |
94 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
95 | 123 | | |
96 | 124 | | |
97 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| |||
96 | 112 | | |
97 | 113 | | |
98 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
99 | 127 | | |
100 | 128 | | |
101 | 129 | | |
| |||
0 commit comments