Skip to content

Commit

Permalink
Merge branch 'remove-url-validation' into 'master'
Browse files Browse the repository at this point in the history
Removed strict URL validation that enforced URLs to start with https://

See merge request cidaas-management/terraform!91
  • Loading branch information
Tujit Bora committed Jul 11, 2024
2 parents a0f0387 + c49de37 commit 7cce4ca
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 140 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Changelog

### 3.0.1

#### Removed
- **URL Validation**: Removed strict URL validation that enforced URLs to start with `https://`.

### 3.0.0

This new release is based on Terraform Plugin Framework and is designed to be mostly backwards compatible with existing implementations. It offers several benefits including enhanced performance, improved debugging capabilities and streamlined development processes. Specific advantages include:
Expand Down
94 changes: 0 additions & 94 deletions internal/resources/app_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ func (r *AppResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
ElementType: types.StringType,
Optional: true,
MarkdownDescription: "Redirect URIs for OAuth2 client.",
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
),
},
PlanModifiers: []planmodifier.Set{
&setCustomRequired{},
},
Expand All @@ -135,14 +127,6 @@ func (r *AppResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
ElementType: types.StringType,
Optional: true,
MarkdownDescription: "Allowed logout URLs for OAuth2 client.",
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
),
},
PlanModifiers: []planmodifier.Set{
&setCustomRequired{},
},
Expand Down Expand Up @@ -227,12 +211,6 @@ func (r *AppResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
PlanModifiers: []planmodifier.String{
&stringCustomRequired{},
},
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"allowed_scopes": schema.SetAttribute{
ElementType: types.StringType,
Expand Down Expand Up @@ -374,32 +352,14 @@ func (r *AppResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
"policy_uri": schema.StringAttribute{
Optional: true,
MarkdownDescription: "The URL to the policy of a client.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"tos_uri": schema.StringAttribute{
Optional: true,
MarkdownDescription: "The URL to the TOS of a client.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"imprint_uri": schema.StringAttribute{
Optional: true,
MarkdownDescription: "The URL to the imprint page.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"contacts": schema.SetAttribute{
ElementType: types.StringType,
Expand Down Expand Up @@ -430,14 +390,6 @@ func (r *AppResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
ElementType: types.StringType,
Optional: true,
MarkdownDescription: "A list of URLs for web messages used.",
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
),
},
},
"social_providers": schema.ListNestedAttribute{
Optional: true,
Expand Down Expand Up @@ -778,30 +730,12 @@ func (r *AppResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
},
"logo_uri": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"initiate_login_uri": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"registration_client_uri": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"registration_access_token": schema.StringAttribute{
Optional: true,
Expand Down Expand Up @@ -906,22 +840,10 @@ func (r *AppResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"video_url": schema.StringAttribute{
Optional: true,
MarkdownDescription: "The URL to the video of the client.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"bot_captcha_ref": schema.StringAttribute{
Optional: true,
Expand Down Expand Up @@ -979,26 +901,10 @@ func getCommonConfig() schema.SingleNestedAttribute {
"redirect_uris": schema.SetAttribute{
ElementType: types.StringType,
Optional: true,
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
),
},
},
"allowed_logout_urls": schema.SetAttribute{
ElementType: types.StringType,
Optional: true,
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
),
},
},
"allowed_web_origins": schema.SetAttribute{
ElementType: types.StringType,
Expand Down
26 changes: 0 additions & 26 deletions internal/resources/resource_custom_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package resources
import (
"context"
"fmt"
"regexp"
"strings"

"github.com/Cidaas/terraform-provider-cidaas/helpers/cidaas"
Expand Down Expand Up @@ -141,12 +140,6 @@ func (r *CustomProvider) Schema(_ context.Context, _ resource.SchemaRequest, res
"logo_url": schema.StringAttribute{
Optional: true,
MarkdownDescription: "The URL for the provider's logo.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"standard_type": schema.StringAttribute{
Optional: true,
Expand All @@ -167,33 +160,14 @@ func (r *CustomProvider) Schema(_ context.Context, _ resource.SchemaRequest, res
"authorization_endpoint": schema.StringAttribute{
Required: true,
MarkdownDescription: "The URL for authorization of the provider.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"token_endpoint": schema.StringAttribute{
Required: true,
MarkdownDescription: "The URL to generate token with this provider.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"userinfo_endpoint": schema.StringAttribute{
Required: true,
MarkdownDescription: "The URL to fetch user details using this provider.",
Validators: []validator.String{
// hcpvalidator.URL(),
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
// In plan Set deletes an existing record and create a whole new one, so preferred list. However, to allow only unique values use set
"scopes": schema.ListNestedAttribute{
Expand Down
7 changes: 0 additions & 7 deletions internal/resources/resource_hosted_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package resources
import (
"context"
"fmt"
"regexp"

"github.com/Cidaas/terraform-provider-cidaas/helpers/cidaas"
"github.com/Cidaas/terraform-provider-cidaas/helpers/util"
Expand Down Expand Up @@ -162,12 +161,6 @@ func (r *HostedPageResource) Schema(_ context.Context, _ resource.SchemaRequest,
"url": schema.StringAttribute{
Required: true,
MarkdownDescription: "The URL for the hosted page.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"content": schema.StringAttribute{
Optional: true,
Expand Down
7 changes: 0 additions & 7 deletions internal/resources/resource_user_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package resources
import (
"context"
"fmt"
"regexp"

"github.com/Cidaas/terraform-provider-cidaas/helpers/cidaas"
"github.com/Cidaas/terraform-provider-cidaas/internal/validators"
Expand Down Expand Up @@ -114,12 +113,6 @@ func (r *UserGroupResource) Schema(_ context.Context, _ resource.SchemaRequest,
"logo_url": schema.StringAttribute{
Optional: true,
MarkdownDescription: "URL for the user group's logo",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"description": schema.StringAttribute{
Optional: true,
Expand Down
6 changes: 0 additions & 6 deletions internal/resources/resource_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ func (r *WebhookResource) Schema(_ context.Context, _ resource.SchemaRequest, re
"url": schema.StringAttribute{
Required: true,
Description: "The webhook url that needs to be called when an event occurs.",
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^https://.+$`),
"must be a valid URL starting with https://",
),
},
},
"events": schema.SetAttribute{
ElementType: types.StringType,
Expand Down

0 comments on commit 7cce4ca

Please sign in to comment.