Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for pki auth #94

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ make release-docker-multi-arch
# database password
password=""

# authentication mode: internal (for server), external (LDAP, etc.)
# authentication mode: internal (for server), external (LDAP, etc.), pki
auth_mode=""
```

Expand Down
2 changes: 1 addition & 1 deletion ape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ user = ""
# database password
password = ""

# authentication mode: internal (for server), external (LDAP, etc.)
# authentication mode: internal (for server), external (LDAP, etc.), pki
auth_mode = ""

# timeout for sending commands to the server node in seconds
Expand Down
2 changes: 1 addition & 1 deletion ape.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ user = "${AS_AUTH_USER}"
# database password
password = "${AS_AUTH_PASSWORD}"

# authentication mode: internal (for server), external (LDAP, etc.)
# authentication mode: internal (for server), external (LDAP, etc.), pki
auth_mode = "${AS_AUTH_MODE}"

# timeout for sending commands to the server node in seconds
Expand Down
7 changes: 5 additions & 2 deletions observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func newObserver(server *aero.Host, user, pass string) (o *Observer, err error)

// use all cpus in the system for concurrency
authMode := strings.ToLower(strings.TrimSpace(config.Aerospike.AuthMode))
if authMode != "internal" && authMode != "external" {
log.Fatalln("Invalid auth mode: only `internal` and `external` values are accepted.")
if authMode != "internal" && authMode != "external" && authMode != "pki" {
log.Fatalln("Invalid auth mode: only `internal`, `external`, `pki` values are accepted.")
}

// Get aerospike auth username
Expand All @@ -101,8 +101,11 @@ func newObserver(server *aero.Host, user, pass string) (o *Observer, err error)
clientPolicy := aero.NewClientPolicy()
clientPolicy.User = string(username)
clientPolicy.Password = string(password)

if authMode == "external" {
clientPolicy.AuthMode = aero.AuthModeExternal
} else if authMode == "pki" {
clientPolicy.AuthMode = aero.AuthModePKI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if authMode == "external" {
clientPolicy.AuthMode = aero.AuthModeExternal
} else if authMode == "pki" {
clientPolicy.AuthMode = aero.AuthModePKI
switch authMode {
case "internal":
clientPolicy.AuthMode = aero.AuthModeInternal
case "external":
clientPolicy.AuthMode = aero.AuthModeExternal
case "pki":
clientPolicy.AuthMode = aero.AuthModePKI
default:
log.Fatalln("Invalid auth mode: only `internal`, `external`, `pki` values are accepted.")
}

and remove line 85-86

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I also added the default value of "" as an option.

}

// allow only ONE connection
Expand Down
2 changes: 1 addition & 1 deletion tests/default_ape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ user = ""
# database password
password = ""

# authentication mode: internal (for server), external (LDAP, etc.)
# authentication mode: internal (for server), external (LDAP, etc.), pki
auth_mode = ""

# timeout for sending commands to the server node in seconds
Expand Down
2 changes: 1 addition & 1 deletion tests/labels_ape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ user = ""
# database password
password = ""

# authentication mode: internal (for server), external (LDAP, etc.)
# authentication mode: internal (for server), external (LDAP, etc.), pki
auth_mode = ""

# timeout for sending commands to the server node in seconds
Expand Down
2 changes: 1 addition & 1 deletion tests/ns_allowlist_ape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ user = ""
# database password
password = ""

# authentication mode: internal (for server), external (LDAP, etc.)
# authentication mode: internal (for server), external (LDAP, etc.), pki
auth_mode = ""

# timeout for sending commands to the server node in seconds
Expand Down
2 changes: 1 addition & 1 deletion tests/ns_blocklist_ape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ user = ""
# database password
password = ""

# authentication mode: internal (for server), external (LDAP, etc.)
# authentication mode: internal (for server), external (LDAP, etc.), pki
auth_mode = ""

# timeout for sending commands to the server node in seconds
Expand Down