diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go b/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go index 5b191084c..3eebac855 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go @@ -38,6 +38,7 @@ func newCreatePostureCheckCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer cmd.AddCommand(newCreatePostureCheckDomainCmd(f, out, errOut)) cmd.AddCommand(newCreatePostureCheckProcessCmd(f, out, errOut)) cmd.AddCommand(newCreatePostureCheckOsCmd(f, out, errOut)) + cmd.AddCommand(newCreatePostureCheckMfaCmd(f, out, errOut)) return cmd } @@ -225,6 +226,7 @@ const ( PostureCheckTypeProcess = "PROCESS" PostureCheckTypeMAC = "MAC" PostureCheckTypeOS = "OS" + PostureCheckTypeMFA = "MFA" ) // Returns the normalized Edge API value or empty string @@ -538,3 +540,62 @@ func parseOsSpec(osSpecStr string) (*osSpec, error) { Versions: cleanVersions, }, nil } + + +func newCreatePostureCheckMfaCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { + options := createPostureCheckOptions{ + edgeOptions: edgeOptions{ + CommonOptions: common.CommonOptions{ + Factory: f, + Out: out, + Err: errOut, + }, + }, + tags: make(map[string]string), + } + + cmd := &cobra.Command{ + Use: "mfa ", + Short: "creates a posture check indicating client-side mfa is required", + Args: func(cmd *cobra.Command, args []string) error { + if err := cobra.MinimumNArgs(1)(cmd, args); err != nil { + return err + } + + return nil + }, + Run: func(cmd *cobra.Command, args []string) { + options.Cmd = cmd + options.Args = args + + err := runCreatePostureCheckMfa(&options) + cmdhelper.CheckErr(err) + }, + SuggestFor: []string{}, + } + + // allow interspersing positional args and flags + cmd.Flags().SetInterspersed(true) + options.AddCommonFlags(cmd) + options.addPostureFlags(cmd) + + return cmd +} +func runCreatePostureCheckMfa(o *createPostureCheckOptions) error { + entityData := gabs.New() + setPostureCheckEntityValues(entityData, o, PostureCheckTypeMFA) + + result, err := createEntityOfType("posture-checks", entityData.String(), &o.edgeOptions) + + if err != nil { + panic(err) + } + + checkId := result.S("data", "id").Data() + + if _, err = fmt.Fprintf(o.Out, "%v\n", checkId); err != nil { + panic(err) + } + + return nil +} \ No newline at end of file diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go b/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go index 89b996705..cb54c9efd 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go @@ -88,7 +88,7 @@ func runCreateServicePolicy(o *createServicePolicyOptions) error { return err } - postureCheckRoles, err := convertNamesToIds(o.postureCheckRoles, "postureChecks", o.edgeOptions) + postureCheckRoles, err := convertNamesToIds(o.postureCheckRoles, "posture-checks", o.edgeOptions) if err != nil { return err }