diff --git a/go.mod b/go.mod index 60869d1a5b..ec5657661f 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 - github.com/manicminer/hamilton v0.62.0 + github.com/manicminer/hamilton v0.62.1-0.20230726233245-cf9bdef22d9d golang.org/x/text v0.9.0 ) diff --git a/go.sum b/go.sum index 70b2314937..afcde97afb 100644 --- a/go.sum +++ b/go.sum @@ -204,8 +204,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/manicminer/hamilton v0.62.0 h1:auy910L0VntDUDHMG6K6e6jr5QUk3OHSldt13NHztwY= -github.com/manicminer/hamilton v0.62.0/go.mod h1:va/X2sztcgQ5+BSxc2eU3FTHYIyxLnHvB4LudlPUZdE= +github.com/manicminer/hamilton v0.62.1-0.20230726233245-cf9bdef22d9d h1:QM7cvxKWKjZCSF8U1xGVPy6TTBTHV05LRAHJ2LZc/54= +github.com/manicminer/hamilton v0.62.1-0.20230726233245-cf9bdef22d9d/go.mod h1:va/X2sztcgQ5+BSxc2eU3FTHYIyxLnHvB4LudlPUZdE= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= diff --git a/vendor/github.com/manicminer/hamilton/msgraph/authentication_strength_policy.go b/vendor/github.com/manicminer/hamilton/msgraph/authentication_strength_policy.go new file mode 100644 index 0000000000..25efbe5e89 --- /dev/null +++ b/vendor/github.com/manicminer/hamilton/msgraph/authentication_strength_policy.go @@ -0,0 +1,158 @@ +package msgraph + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// AuthenticationStrengthPoliciesClient performs operations on AuthenticationStrengthPolicy. +type AuthenticationStrengthPoliciesClient struct { + BaseClient Client +} + +// NewAuthenticationStrengthPoliciesClient returns a new AuthenticationStrengthPoliciesClient +func NewAuthenticationStrengthPoliciesClient() *AuthenticationStrengthPoliciesClient { + return &AuthenticationStrengthPoliciesClient{ + BaseClient: NewClient(VersionBeta), + } +} + +// List returns a list of AuthenticationStrengthPolicy, optionally queried using OData. +func (c *AuthenticationStrengthPoliciesClient) List(ctx context.Context, query odata.Query) (*[]AuthenticationStrengthPolicy, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: "/policies/authenticationStrengthPolicies", + }, + }) + if err != nil { + return nil, status, fmt.Errorf("AuthenticationStrengthPoliciesClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var data struct { + AuthenticationStrengthPolicys []AuthenticationStrengthPolicy `json:"value"` + } + if err := json.Unmarshal(respBody, &data); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &data.AuthenticationStrengthPolicys, status, nil +} + +// Create creates a new AuthenticationStrengthPolicy. +func (c *AuthenticationStrengthPoliciesClient) Create(ctx context.Context, authenticationStrengthPolicy AuthenticationStrengthPolicy) (*AuthenticationStrengthPolicy, int, error) { + var status int + body, err := json.Marshal(authenticationStrengthPolicy) + if err != nil { + return nil, status, fmt.Errorf("json.Marshal(): %v", err) + } + + resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ + Body: body, + ValidStatusCodes: []int{http.StatusCreated}, + Uri: Uri{ + Entity: "/policies/authenticationStrengthPolicies", + }, + }) + if err != nil { + return nil, status, fmt.Errorf("AuthenticationStrengthPoliciesClient.BaseClient.Post(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var newAuthenticationStrengthPolicy AuthenticationStrengthPolicy + if err := json.Unmarshal(respBody, &newAuthenticationStrengthPolicy); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &newAuthenticationStrengthPolicy, status, nil +} + +// Get retrieves a AuthenticationStrengthPolicy. +func (c *AuthenticationStrengthPoliciesClient) Get(ctx context.Context, id string, query odata.Query) (*AuthenticationStrengthPolicy, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: fmt.Sprintf("/policies/authenticationStrengthPolicies/%s", id), + }, + }) + if err != nil { + return nil, status, fmt.Errorf("AuthenticationStrengthPoliciesClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var AuthenticationStrengthPolicy AuthenticationStrengthPolicy + if err := json.Unmarshal(respBody, &AuthenticationStrengthPolicy); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &AuthenticationStrengthPolicy, status, nil +} + +// Update amends an existing AuthenticationStrengthPolicy. +func (c *AuthenticationStrengthPoliciesClient) Update(ctx context.Context, AuthenticationStrengthPolicy AuthenticationStrengthPolicy) (int, error) { + var status int + + if AuthenticationStrengthPolicy.ID == nil { + return status, errors.New("cannot update AuthenticationStrengthPolicy with nil ID") + } + + body, err := json.Marshal(AuthenticationStrengthPolicy) + if err != nil { + return status, fmt.Errorf("json.Marshal(): %v", err) + } + + _, status, _, err = c.BaseClient.Patch(ctx, PatchHttpRequestInput{ + Body: body, + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{http.StatusNoContent}, + Uri: Uri{ + Entity: fmt.Sprintf("/policies/authenticationStrengthPolicies/%s", *AuthenticationStrengthPolicy.ID), + }, + }) + if err != nil { + return status, fmt.Errorf("AuthenticationStrengthPoliciesClient.BaseClient.Patch(): %v", err) + } + + return status, nil +} + +// Delete removes a AuthenticationStrengthPolicy. +func (c *AuthenticationStrengthPoliciesClient) Delete(ctx context.Context, id string) (int, error) { + _, status, _, err := c.BaseClient.Delete(ctx, DeleteHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{http.StatusNoContent}, + Uri: Uri{ + Entity: fmt.Sprintf("/policies/authenticationStrengthPolicies/%s/$ref", id), + }, + }) + if err != nil { + return status, fmt.Errorf("AuthenticationStrengthPoliciesClient.BaseClient.Delete(): %v", err) + } + + return status, nil +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/models.go b/vendor/github.com/manicminer/hamilton/msgraph/models.go index 05f8093a41..c2a8b6363a 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/models.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/models.go @@ -582,6 +582,16 @@ type AuditActivityInitiator struct { type AuthenticationMethod interface{} +type AuthenticationStrengthPolicy struct { + AllowedCombinations *[]AuthenticationMethodModes `json:"allowedCombinations,omitempty"` + CreatedDateTime *time.Time `json:"createdDateTime,omitempty"` + ID *string `json:"id,omitempty"` + ModifiedDateTime *time.Time `json:"modifiedDateTime,omitempty"` + PolicyType *AuthenticationStrengthPolicyType `json:"policyType,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` +} + type BaseNamedLocation struct { ODataType *odata.Type `json:"@odata.type,omitempty"` ID *string `json:"id,omitempty"` @@ -646,6 +656,7 @@ type ConditionalAccessFilter struct { type ConditionalAccessGrantControls struct { Operator *string `json:"operator,omitempty"` + AuthenticationStrength *AuthenticationStrengthPolicy `json:"authenticationStrength,omitempty"` BuiltInControls *[]ConditionalAccessGrantControl `json:"builtInControls,omitempty"` CustomAuthenticationFactors *[]string `json:"customAuthenticationFactors,omitempty"` TermsOfUse *[]string `json:"termsOfUse,omitempty"` diff --git a/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go b/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go index e9e321c838..92d7cd66d9 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go @@ -131,8 +131,9 @@ const ( type AccessReviewReviewerType = string const ( - AccessReviewReviewerTypeSelf AccessReviewReviewerType = "Self" + AccessReviewReviewerTypeManager AccessReviewReviewerType = "Manager" AccessReviewReviewerTypeReviewers AccessReviewReviewerType = "Reviewers" + AccessReviewReviewerTypeSelf AccessReviewReviewerType = "Self" ) type AccessReviewRecurranceType = string @@ -251,6 +252,28 @@ const ( AuthenticationMethodKeyStrengthUnknown AuthenticationMethodKeyStrength = "unknown" ) +type AuthenticationMethodModes = string + +const ( + AuthenticationMethodModesEmail AuthenticationMethodModes = "email" + AuthenticationMethodModesFederatedMultiFactor AuthenticationMethodModes = "federatedMultiFactor" + AuthenticationMethodModesFederatedSingleFactor AuthenticationMethodModes = "federatedSingleFactor" + AuthenticationMethodModesFido2 AuthenticationMethodModes = "fido2" + AuthenticationMethodModesHardwareOath AuthenticationMethodModes = "hardwareOath" + AuthenticationMethodModesMicrosoftAuthenticatorPush AuthenticationMethodModes = "microsoftAuthenticatorPush" + AuthenticationMethodModesMicrosoftDeviceBasedPush AuthenticationMethodModes = "deviceBasedPush" + AuthenticationMethodModesPassword AuthenticationMethodModes = "password" + AuthenticationMethodModesSms AuthenticationMethodModes = "sms" + AuthenticationMethodModesSoftwareOath AuthenticationMethodModes = "softwareOath" + AuthenticationMethodModesTemporaryAccessPassMultiUse AuthenticationMethodModes = "temporaryAccessPassMultiUse" + AuthenticationMethodModesTemporaryAccessPassOneTime AuthenticationMethodModes = "temporaryAccessPassOneTime" + AuthenticationMethodModesUnknownFutureValue AuthenticationMethodModes = "unknownFutureValue" + AuthenticationMethodModesVoice AuthenticationMethodModes = "voice" + AuthenticationMethodModesWindowsHelloForBusiness AuthenticationMethodModes = "windowsHelloForBusiness" + AuthenticationMethodModesX509CertificateMultiFactor AuthenticationMethodModes = "x509CertificateMultiFactor" + AuthenticationMethodModesX509CertificateSingleFactor AuthenticationMethodModes = "x509CertificateSingleFactor" +) + type AuthenticationPhoneType = string const ( @@ -259,6 +282,14 @@ const ( AuthenticationPhoneTypeOffice AuthenticationPhoneType = "office" ) +type AuthenticationStrengthPolicyType = string + +const ( + AuthenticationStrengthPolicyTypeBuiltIn AuthenticationStrengthPolicyType = "builtIn" + AuthenticationStrengthPolicyTypeCustom AuthenticationStrengthPolicyType = "custom" + AuthenticationStrengthPolicyTypeUnknownFutureValue AuthenticationStrengthPolicyType = "unknownFutureValue" +) + type BodyType = string const ( diff --git a/vendor/modules.txt b/vendor/modules.txt index 54b6ec46b8..7433647aaf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -158,7 +158,7 @@ github.com/hashicorp/terraform-svchost # github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 ## explicit; go 1.15 github.com/hashicorp/yamux -# github.com/manicminer/hamilton v0.62.0 +# github.com/manicminer/hamilton v0.62.1-0.20230726233245-cf9bdef22d9d ## explicit; go 1.16 github.com/manicminer/hamilton/errors github.com/manicminer/hamilton/internal/utils