Skip to content

Commit

Permalink
APPS-1400 Remove EXTERNAL_INSECURE auth mode (#290)
Browse files Browse the repository at this point in the history
remove EXTERNAL_INSECURE
  • Loading branch information
korotkov-aerospike authored Dec 23, 2024
1 parent 0dce781 commit 49b9e8e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,10 @@ Validation allows only one of these three fields to be present.
properties:
auth-mode:
description: >-
The authentication mode string (INTERNAL, EXTERNAL,
EXTERNAL_INSECURE, PKI).
The authentication mode string (INTERNAL, EXTERNAL, PKI).
enum:
- INTERNAL
- EXTERNAL
- EXTERNAL_INSECURE
- PKI
type: string
password:
Expand Down
3 changes: 1 addition & 2 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2030,12 +2030,11 @@ const docTemplate = `{
"type": "object",
"properties": {
"auth-mode": {
"description": "The authentication mode string (INTERNAL, EXTERNAL, EXTERNAL_INSECURE, PKI).",
"description": "The authentication mode string (INTERNAL, EXTERNAL, PKI).",
"type": "string",
"enum": [
"INTERNAL",
"EXTERNAL",
"EXTERNAL_INSECURE",
"PKI"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2217,8 +2217,8 @@
"description" : "Credentials represents authentication details to the Aerospike cluster.",
"properties" : {
"auth-mode" : {
"description" : "The authentication mode string (INTERNAL, EXTERNAL, EXTERNAL_INSECURE, PKI).",
"enum" : [ "INTERNAL", "EXTERNAL", "EXTERNAL_INSECURE", "PKI" ],
"description" : "The authentication mode string (INTERNAL, EXTERNAL, PKI).",
"enum" : [ "INTERNAL", "EXTERNAL", "PKI" ],
"type" : "string"
},
"password" : {
Expand Down
4 changes: 1 addition & 3 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1745,12 +1745,10 @@ components:
cluster.
properties:
auth-mode:
description: "The authentication mode string (INTERNAL, EXTERNAL, EXTERNAL_INSECURE,\
\ PKI)."
description: "The authentication mode string (INTERNAL, EXTERNAL, PKI)."
enum:
- INTERNAL
- EXTERNAL
- EXTERNAL_INSECURE
- PKI
type: string
password:
Expand Down
12 changes: 10 additions & 2 deletions pkg/dto/aerospike_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io"
"strings"

"github.com/aerospike/aerospike-backup-service/v2/pkg/model"
)
Expand Down Expand Up @@ -176,8 +177,8 @@ type Credentials struct {
Password *string `yaml:"password,omitempty" json:"password,omitempty" example:"testPswd"`
// The file path with the password string.
PasswordPath *string `yaml:"password-path,omitempty" json:"password-path,omitempty" example:"/path/to/pass.txt"`
// The authentication mode string (INTERNAL, EXTERNAL, EXTERNAL_INSECURE, PKI).
AuthMode *string `yaml:"auth-mode,omitempty" json:"auth-mode,omitempty" enums:"INTERNAL,EXTERNAL,EXTERNAL_INSECURE,PKI"`
// The authentication mode string (INTERNAL, EXTERNAL, PKI).
AuthMode *string `yaml:"auth-mode,omitempty" json:"auth-mode,omitempty" enums:"INTERNAL,EXTERNAL,PKI"`
}

func (c *Credentials) fromModel(m *model.Credentials, config *model.Config) {
Expand Down Expand Up @@ -205,6 +206,13 @@ func (c *Credentials) Validate() error {
return fmt.Errorf("password and password-path are mutually exclusive")
}

if c.AuthMode != nil &&
!(strings.ToUpper(*c.AuthMode) == "INTERNAL" ||
strings.ToUpper(*c.AuthMode) == "EXTERNAL" ||
strings.ToUpper(*c.AuthMode) == "PKI") {
return fmt.Errorf("auth-mode %q incorrect, should be one of: INTERNAL,EXTERNAL,PKI", *c.AuthMode)
}

return c.SecretAgentConfig.validate()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/model/aerospike_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ type Credentials struct {
Password *string
// The file path with the password string, will take precedence over the password field.
PasswordPath *string
// The authentication mode string (INTERNAL, EXTERNAL, EXTERNAL_INSECURE, PKI).
// The authentication mode string (INTERNAL, EXTERNAL, PKI).
AuthMode *string
// The name of the configured Secret Agent to use for authentication.
SecretAgent *SecretAgent
Expand Down

0 comments on commit 49b9e8e

Please sign in to comment.