Skip to content

Commit 7f1631c

Browse files
authored
auth: ensure machines are allowed in when pak change (#2917)
1 parent f658a8e commit 7f1631c

File tree

19 files changed

+692
-123
lines changed

19 files changed

+692
-123
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
108

119
concurrency:
1210
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}

.github/workflows/test-integration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
- TestAuthKeyLogoutAndReloginSameUser
3333
- TestAuthKeyLogoutAndReloginNewUser
3434
- TestAuthKeyLogoutAndReloginSameUserExpiredKey
35+
- TestAuthKeyDeleteKey
3536
- TestOIDCAuthenticationPingAll
3637
- TestOIDCExpireNodesBasedOnTokenExpiry
3738
- TestOIDC024UserCreation

cmd/headscale/cli/preauthkeys.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func init() {
3434
preauthkeysCmd.AddCommand(listPreAuthKeys)
3535
preauthkeysCmd.AddCommand(createPreAuthKeyCmd)
3636
preauthkeysCmd.AddCommand(expirePreAuthKeyCmd)
37+
preauthkeysCmd.AddCommand(deletePreAuthKeyCmd)
3738
createPreAuthKeyCmd.PersistentFlags().
3839
Bool("reusable", false, "Make the preauthkey reusable")
3940
createPreAuthKeyCmd.PersistentFlags().
@@ -232,3 +233,43 @@ var expirePreAuthKeyCmd = &cobra.Command{
232233
SuccessOutput(response, "Key expired", output)
233234
},
234235
}
236+
237+
var deletePreAuthKeyCmd = &cobra.Command{
238+
Use: "delete KEY",
239+
Short: "Delete a preauthkey",
240+
Aliases: []string{"del", "rm", "d"},
241+
Args: func(cmd *cobra.Command, args []string) error {
242+
if len(args) < 1 {
243+
return errMissingParameter
244+
}
245+
246+
return nil
247+
},
248+
Run: func(cmd *cobra.Command, args []string) {
249+
output, _ := cmd.Flags().GetString("output")
250+
user, err := cmd.Flags().GetUint64("user")
251+
if err != nil {
252+
ErrorOutput(err, fmt.Sprintf("Error getting user: %s", err), output)
253+
}
254+
255+
ctx, client, conn, cancel := newHeadscaleCLIWithConfig()
256+
defer cancel()
257+
defer conn.Close()
258+
259+
request := &v1.DeletePreAuthKeyRequest{
260+
User: user,
261+
Key: args[0],
262+
}
263+
264+
response, err := client.DeletePreAuthKey(ctx, request)
265+
if err != nil {
266+
ErrorOutput(
267+
err,
268+
fmt.Sprintf("Cannot delete Pre Auth Key: %s\n", err),
269+
output,
270+
)
271+
}
272+
273+
SuccessOutput(response, "Key deleted", output)
274+
},
275+
}

cmd/hi/docker.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ func createGoTestContainer(ctx context.Context, cli *client.Client, config *RunC
202202
fmt.Sprintf("HEADSCALE_INTEGRATION_POSTGRES=%d", boolToInt(config.UsePostgres)),
203203
"HEADSCALE_INTEGRATION_RUN_ID=" + runID,
204204
}
205+
206+
// Pass through all HEADSCALE_INTEGRATION_* environment variables
207+
for _, e := range os.Environ() {
208+
if strings.HasPrefix(e, "HEADSCALE_INTEGRATION_") {
209+
// Skip the ones we already set explicitly
210+
if strings.HasPrefix(e, "HEADSCALE_INTEGRATION_POSTGRES=") ||
211+
strings.HasPrefix(e, "HEADSCALE_INTEGRATION_RUN_ID=") {
212+
continue
213+
}
214+
env = append(env, e)
215+
}
216+
}
205217
containerConfig := &container.Config{
206218
Image: "golang:" + config.GoVersion,
207219
Cmd: goTestCmd,

gen/go/headscale/v1/headscale.pb.go

Lines changed: 95 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/go/headscale/v1/headscale.pb.gw.go

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/go/headscale/v1/headscale_grpc.pb.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)