Skip to content

Commit e000fda

Browse files
authored
Merge pull request #564 from nnmin-aws/nnmin-minorimp
prepare new release v0.6.4
2 parents 54856dd + 3a0571c commit e000fda

File tree

17 files changed

+211
-76
lines changed

17 files changed

+211
-76
lines changed

.goreleaser.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ builds:
1212
goarch:
1313
- amd64
1414
- arm64
15+
- ppc64le
16+
- s390x
1517
ignore:
1618
- goos: windows
1719
goarch: arm64

cloudbuild.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
options:
22
substitution_option: ALLOW_LOOSE
33
steps:
4-
- name: gcr.io/k8s-testimages/gcb-docker-gcloud
4+
- name: gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20221214-1b4dd4d69a
55
entrypoint: /buildx-entrypoint
66
args:
7-
- build
8-
- --tag=gcr.io/$PROJECT_ID/aws-iam-authenticator:$_GIT_TAG
9-
- --tag=gcr.io/$PROJECT_ID/aws-iam-authenticator:latest
10-
- --platform=linux/amd64,linux/arm64
11-
- --output=type=registry
12-
- .
7+
- build
8+
- --tag=gcr.io/$PROJECT_ID/aws-iam-authenticator:$_GIT_TAG
9+
- --tag=gcr.io/$PROJECT_ID/aws-iam-authenticator:latest
10+
- --platform=linux/amd64,linux/arm64
11+
- --output=type=registry
12+
- .
1313
substitutions:
1414
_GIT_TAG: '12345'
1515
_PULL_BASE_REF: 'master'

cmd/aws-iam-authenticator/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func getConfig() (config.Config, error) {
104104
EC2DescribeInstancesBurst: viper.GetInt("server.ec2DescribeInstancesBurst"),
105105
ScrubbedAWSAccounts: viper.GetStringSlice("server.scrubbedAccounts"),
106106
DynamicFilePath: viper.GetString("server.dynamicfilepath"),
107+
DynamicFileUserIDStrict: viper.GetBool("server.dynamicfileUserIDStrict"),
107108
}
108109
if err := viper.UnmarshalKey("server.mapRoles", &cfg.RoleMappings); err != nil {
109110
return cfg, fmt.Errorf("invalid server role mappings: %v", err)

hack/dev/access-entries.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"username": "kubernetes-admin",
66
"groups": [
77
"system:masters"
8-
]
8+
],
9+
"userid": "{{USER_ID}}"
910
}
1011
]
1112
}

hack/e2e-dynamicfile.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ function e2e_dynamicfile(){
103103
echo "can't assume-role: "${AWS_TEST_ROLE}
104104
exit 1
105105
fi
106-
106+
USERID=$(aws sts get-caller-identity|jq -r '.UserId'|cut -d: -f1)
107+
echo "userid: " $USERID
107108
#run kubectl cmd without adding the role into access entry
108109
if [ -f ${access_entry_json} ]
109110
then
@@ -123,6 +124,7 @@ function e2e_dynamicfile(){
123124

124125
sed -e "s|{{AWS_ACCOUNT}}|${AWS_ACCOUNT}|g" \
125126
-e "s|{{AWS_TEST_ROLE}}|${AWS_TEST_ROLE}|g" \
127+
-e "s|{{USER_ID}}|${USERID}|g" \
126128
"${access_entry_template}" > "${access_entry_tmp}"
127129
mv "${access_entry_tmp}" "${access_entry_json}"
128130
#sleep 10 seconds to make access entry effective

hack/lib/dev-env.sh

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ NETWORK_NAME="${NETWORK_NAME:-authenticator-dev}"
4646
NETWORK_SUBNET="${NETWORK_SUBNET:-172.30.0.0/16}"
4747
AUTHENTICATOR_IP="${AUTHENTICATOR_IP:-172.30.0.10}"
4848
AUTHENTICATOR_PORT="${AUTHENTICATOR_PORT:-21362}"
49+
KIND_BIN="${KIND_BIN:-${OUTPUT}/bin/kind}"
4950

5051
# Not configurable:
5152
authenticator_healthz_port=21363
@@ -85,16 +86,19 @@ kubectl_kubeconfig="${client_dir}/kubeconfig.yaml"
8586
kind_kubeconfig="${client_dir}/kind-kubeconfig.yaml"
8687

8788
function install_kind() {
88-
if [[ "$OSTYPE" == "darwin"* ]]; then
89-
# for Intel Macs
90-
[ $(uname -m) = x86_64 ]&& curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-darwin-amd64
91-
# for M1 / ARM Macs
92-
[ $(uname -m) = arm64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-darwin-arm64
93-
else
94-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
95-
fi
96-
chmod +x ./kind
97-
command -v ./kind >/dev/null 2>&1 || { echo >&2 "kind is required but it's not installed. Aborting."; exit 1; }
89+
if ! [[ -f "${KIND_BIN}" ]]; then
90+
if [[ "$OSTYPE" == "darwin"* ]]; then
91+
# for Intel Macs
92+
[ $(uname -m) = x86_64 ]&& curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-darwin-amd64
93+
# for M1 / ARM Macs
94+
[ $(uname -m) = arm64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-darwin-arm64
95+
else
96+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
97+
fi
98+
chmod +x ./kind
99+
mv ./kind "${KIND_BIN}"
100+
fi
101+
command -v "${KIND_BIN}" >/dev/null 2>&1 || { echo >&2 "kind is required but it's not installed. Aborting."; exit 1; }
98102
}
99103

100104
function create_network() {
@@ -234,11 +238,11 @@ function write_kubectl_kubeconfig() {
234238

235239
function create_kind_cluster() {
236240
export KIND_EXPERIMENTAL_DOCKER_NETWORK="${NETWORK_NAME}"
237-
./kind create cluster \
241+
"${KIND_BIN}" create cluster \
238242
--config "${kind_config_host_dir}/env.yaml" \
239243
--kubeconfig "${kind_kubeconfig}"
240244
}
241245

242246
function delete_kind_cluster() {
243-
./kind delete cluster --name "${CLUSTER_NAME}"
244-
}
247+
"${KIND_BIN}" delete cluster --name "${CLUSTER_NAME}"
248+
}

hack/start-dev-env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ fi
4545

4646
source "${REPO_ROOT}/hack/lib/dev-env.sh"
4747

48+
install_kind
4849
create_network
4950
write_authenticator_config
5051
start_authenticator

pkg/config/types.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ type RoleMapping struct {
5252

5353
// Groups is a list of Kubernetes groups this role will authenticate
5454
// as (e.g., `system:masters`). Each group name can include placeholders.
55-
Groups []string `json:"groups"`
55+
Groups []string `json:"groups" yaml:"groups"`
56+
57+
// UserId is the AWS PrincipalId of the role. (e.g., "ABCXSOTJDDV").
58+
UserId string `json:"userid,omitempty" yaml:"userid,omitempty"`
5659
}
5760

5861
// UserMapping is a static mapping of a single AWS User ARN to a
@@ -65,7 +68,10 @@ type UserMapping struct {
6568
Username string `json:"username"`
6669

6770
// Groups is a list of Kubernetes groups this role will authenticate as (e.g., `system:masters`)
68-
Groups []string `json:"groups"`
71+
Groups []string `json:"groups" yaml:"groups"`
72+
73+
// UserId is the AWS PrincipalId of the user. (e.g., "ABCXSOTJDDV").
74+
UserId string `json:"userid,omitempty" yaml:"userid,omitempty"`
6975
}
7076

7177
// Config specifies the configuration for a aws-iam-authenticator server
@@ -144,4 +150,6 @@ type Config struct {
144150
EC2DescribeInstancesBurst int
145151
//Dynamic File Path for DynamicFile BackendMode
146152
DynamicFilePath string
153+
//use UserId for mapping, IdentityArn is not used any more when DynamicFileUserIDStrict=true
154+
DynamicFileUserIDStrict bool
147155
}

pkg/mapper/configmap/mapper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package configmap
22

33
import (
4+
"sigs.k8s.io/aws-iam-authenticator/pkg/token"
45
"strings"
56

67
"sigs.k8s.io/aws-iam-authenticator/pkg/config"
@@ -30,8 +31,8 @@ func (m *ConfigMapMapper) Start(stopCh <-chan struct{}) error {
3031
return nil
3132
}
3233

33-
func (m *ConfigMapMapper) Map(canonicalARN string) (*config.IdentityMapping, error) {
34-
canonicalARN = strings.ToLower(canonicalARN)
34+
func (m *ConfigMapMapper) Map(identity *token.Identity) (*config.IdentityMapping, error) {
35+
canonicalARN := strings.ToLower(identity.CanonicalARN)
3536

3637
rm, err := m.RoleMapping(canonicalARN)
3738
// TODO: Check for non Role/UserNotFound errors

pkg/mapper/crd/mapper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package crd
22

33
import (
44
"fmt"
5+
"sigs.k8s.io/aws-iam-authenticator/pkg/token"
56
"strings"
67
"time"
78

@@ -86,8 +87,8 @@ func (m *CRDMapper) Start(stopCh <-chan struct{}) error {
8687
return nil
8788
}
8889

89-
func (m *CRDMapper) Map(canonicalARN string) (*config.IdentityMapping, error) {
90-
canonicalARN = strings.ToLower(canonicalARN)
90+
func (m *CRDMapper) Map(identity *token.Identity) (*config.IdentityMapping, error) {
91+
canonicalARN := strings.ToLower(identity.CanonicalARN)
9192

9293
var iamidentity *iamauthenticatorv1alpha1.IAMIdentityMapping
9394
var ok bool

0 commit comments

Comments
 (0)