mirror of
https://github.com/bitnami/containers.git
synced 2026-02-15 00:57:23 +08:00
[bitnami/keycloak] Add support for ipv6 (#40224)
* Add validate_ipv6 function for keycloak
ip="2001:0db8:85a3:0000:0000:8a2e:0370:7334"
ip="fd00::"
ip="::"
validate_ipv6 "$ip"
result=$?
if [[ $result -eq 0 ]]; then
echo "IPv6 address is valid"
else
echo "IPv6 address is invalid"
fi
Signed-off-by: Louis <covert8@users.noreply.github.com>
Signed-off-by: covert <covert8@users.noreply.github.com>
* Add combinatory fuction for validate ipv4 & ipv6
Signed-off-by: Louis <covert8@users.noreply.github.com>
Signed-off-by: covert <covert8@users.noreply.github.com>
* Use combinated validate_ip function for keycloak envVars check
Signed-off-by: Louis <covert8@users.noreply.github.com>
Signed-off-by: covert <covert8@users.noreply.github.com>
* Fix return error description validate_ip helper function
Co-authored-by: Damiano Albani <damiano.albani@gmail.com>
Signed-off-by: Louis <covert8@users.noreply.github.com>
Signed-off-by: covert <covert8@users.noreply.github.com>
* Small syntax fixes
Signed-off-by: covert <covert8@users.noreply.github.com>
---------
Signed-off-by: Louis <covert8@users.noreply.github.com>
Signed-off-by: covert <covert8@users.noreply.github.com>
Co-authored-by: Damiano Albani <damiano.albani@gmail.com>
This commit is contained in:
@@ -187,6 +187,26 @@ validate_port() {
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Validate if the provided argument is a valid IPv4 or IPv6 address
|
||||
# Arguments:
|
||||
# $1 - IP to validate
|
||||
# Returns:
|
||||
# Boolean
|
||||
#########################
|
||||
validate_ip() {
|
||||
local ip="${1:?ip is missing}"
|
||||
local stat=1
|
||||
|
||||
if validate_ipv4 "$ip"; then
|
||||
stat=0
|
||||
else
|
||||
stat=$(validate_ipv6 "$ip")
|
||||
fi
|
||||
|
||||
return $stat
|
||||
}
|
||||
|
||||
########################
|
||||
# Validate if the provided argument is a valid IPv4 address
|
||||
# Arguments:
|
||||
@@ -207,6 +227,25 @@ validate_ipv4() {
|
||||
return $stat
|
||||
}
|
||||
|
||||
########################
|
||||
# Validate if the provided argument is a valid IPv6 address
|
||||
# Arguments:
|
||||
# $1 - IP to validate
|
||||
# Returns:
|
||||
# Boolean
|
||||
#########################
|
||||
validate_ipv6() {
|
||||
local ip="${1:?ip is missing}"
|
||||
local stat=1
|
||||
local full_address_regex='^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'
|
||||
local short_address_regex='^((([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}){0,6}::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}){0,6})$'
|
||||
|
||||
if [[ $ip =~ $full_address_regex || $ip =~ $short_address_regex || $ip == "::" ]]; then
|
||||
stat=0
|
||||
fi
|
||||
return $stat
|
||||
}
|
||||
|
||||
########################
|
||||
# Validate a string format
|
||||
# Arguments:
|
||||
|
||||
@@ -72,9 +72,9 @@ keycloak_validate() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! validate_ipv4 "${KEYCLOAK_BIND_ADDRESS}"; then
|
||||
if ! validate_ip "${KEYCLOAK_BIND_ADDRESS}"; then
|
||||
if ! is_hostname_resolved "${KEYCLOAK_BIND_ADDRESS}"; then
|
||||
print_validation_error print_validation_error "The value for KEYCLOAK_BIND_ADDRESS ($KEYCLOAK_BIND_ADDRESS) should be an IPv4 address or it must be a resolvable hostname"
|
||||
print_validation_error print_validation_error "The value for KEYCLOAK_BIND_ADDRESS ($KEYCLOAK_BIND_ADDRESS) should be an IPv4 or IPv6 address, or it must be a resolvable hostname"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user