mirror of
https://github.com/juanfont/headscale.git
synced 2025-11-07 04:42:52 -05:00
cli: only validate bypass-grpc set policy (#2854)
This commit is contained in:
@@ -127,12 +127,6 @@ var setPolicy = &cobra.Command{
|
|||||||
ErrorOutput(err, fmt.Sprintf("Error reading the policy file: %s", err), output)
|
ErrorOutput(err, fmt.Sprintf("Error reading the policy file: %s", err), output)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = policy.NewPolicyManager(policyBytes, nil, views.Slice[types.NodeView]{})
|
|
||||||
if err != nil {
|
|
||||||
ErrorOutput(err, fmt.Sprintf("Error parsing the policy file: %s", err), output)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if bypass, _ := cmd.Flags().GetBool(bypassFlag); bypass {
|
if bypass, _ := cmd.Flags().GetBool(bypassFlag); bypass {
|
||||||
confirm := false
|
confirm := false
|
||||||
force, _ := cmd.Flags().GetBool("force")
|
force, _ := cmd.Flags().GetBool("force")
|
||||||
@@ -159,6 +153,17 @@ var setPolicy = &cobra.Command{
|
|||||||
ErrorOutput(err, fmt.Sprintf("Failed to open database: %s", err), output)
|
ErrorOutput(err, fmt.Sprintf("Failed to open database: %s", err), output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
users, err := d.ListUsers()
|
||||||
|
if err != nil {
|
||||||
|
ErrorOutput(err, fmt.Sprintf("Failed to load users for policy validation: %s", err), output)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = policy.NewPolicyManager(policyBytes, users, views.Slice[types.NodeView]{})
|
||||||
|
if err != nil {
|
||||||
|
ErrorOutput(err, fmt.Sprintf("Error parsing the policy file: %s", err), output)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err = d.SetPolicy(string(policyBytes))
|
_, err = d.SetPolicy(string(policyBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorOutput(err, fmt.Sprintf("Failed to set ACL Policy: %s", err), output)
|
ErrorOutput(err, fmt.Sprintf("Failed to set ACL Policy: %s", err), output)
|
||||||
|
|||||||
Reference in New Issue
Block a user