Skip to content

Commit

Permalink
fix: client credentials are not required, add apikey validation (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtejadav authored Nov 8, 2024
1 parent b9b3c41 commit 055848c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/utils/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
)

type ValidationParams struct {
ApiKey string
ClientID string
ClientSecret string
ApiUrl *string
Expand All @@ -31,8 +32,9 @@ type ValidationParams struct {

// UserInputValidaton responsible for input paramerter validation.
type UserInputValidaton struct {
ClientId string `validate:"required,min=36,max=36"`
ClientSecret string `validate:"required,min=36,max=64"`
ApiKey string `validate:"omitempty,min=128,max=263"`
ClientId string `validate:"omitempty,min=36,max=36,required_without=ApiKey"`
ClientSecret string `validate:"omitempty,min=36,max=64,required_without=ApiKey"`
ApiUrl string `validate:"required,http_url"`
ClientTimeOutinSeconds int `validate:"gte=1,lte=300"`
Separator string `validate:"required,min=1,max=1"`
Expand Down Expand Up @@ -71,6 +73,7 @@ func ValidateInputs(params ValidationParams) error {
validate = validator.New(validator.WithRequiredStructEnabled())

userInput := &UserInputValidaton{
ApiKey: params.ApiKey,
ClientId: params.ClientID,
ClientSecret: params.ClientSecret,
ApiUrl: *params.ApiUrl,
Expand Down

0 comments on commit 055848c

Please sign in to comment.