Skip to content

Commit 6d32796

Browse files
committed
Add Identity login automation for dev env
1 parent 7b70b10 commit 6d32796

File tree

6 files changed

+270
-12
lines changed

6 files changed

+270
-12
lines changed

ci/identity/users.template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
- !user test.user3@mycompany.com
33
- !user conjur_ci_user@cyberark.com
44
- !user conj_ops_dev@cyberark.com
5-
- !user {{ IDENTITY_USER }}
5+
- !user {{ IDENTITY_USERNAME }}
66

77
- !grant
88
members:
99
- !user test.user3@mycompany.com
1010
- !user conjur_ci_user@cyberark.com
1111
- !user conj_ops_dev@cyberark.com
12-
- !user {{ IDENTITY_USER }}
12+
- !user {{ IDENTITY_USERNAME }}
1313
role: !group conjur/authn-oidc/identity/authenticatable
1414

1515
- !permit

dev/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ services:
3232
environment:
3333
- OKTA_USERNAME=${OKTA_USERNAME:-user}
3434
- OKTA_PASSWORD=${OKTA_PASSWORD:-password}
35+
- IDENTITY_USERNAME=${IDENTITY_USERNAME:-user}
3536
command: bash -c "cd ${PWD}/..; make install; sleep infinity"
3637
working_dir: ${PWD}/..
3738
restart: on-failure

dev/start

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ source "../ci/keycloak/keycloak_functions.sh"
1616
ENABLE_OIDC_KEYCLOAK=false
1717
ENABLE_OIDC_OKTA=false
1818
ENABLE_OIDC_IDENTITY=false
19-
IDENTITY_USER=""
19+
export IDENTITY_USERNAME=""
2020

2121
# Minimal set of services. We add to this list based on cmd line flags.
2222
services=(pg conjur proxy cli-dev)
@@ -138,7 +138,7 @@ conjur login -i alice -p alice'
138138
echo "Setting up Conjur for OIDC (Identity)"
139139
docker-compose exec cli-dev bash -c 'conjur logout
140140
conjur init --force-netrc --force -u http://conjur -i -a dev -t oidc --service-id identity
141-
conjur login -i $IDENTITY_USERNAME -p $IDENTITY_PASSWORD'
141+
conjur login -i $IDENTITY_USERNAME'
142142
fi
143143

144144
echo
@@ -151,7 +151,7 @@ parse_options() {
151151
--oidc-keycloak ) ENABLE_OIDC_KEYCLOAK=true ; shift ;;
152152
--oidc-okta ) ENABLE_OIDC_OKTA=true ; shift ;;
153153
--oidc-identity ) ENABLE_OIDC_IDENTITY=true ; shift ;;
154-
--identity-user ) IDENTITY_USER="$2" ; shift ; shift ;;
154+
--identity-user ) IDENTITY_USERNAME="$2" ; shift ; shift ;;
155155
# -h | --help ) print_help ; shift ;;
156156
* )
157157
if [ -z "$1" ]; then
@@ -163,7 +163,7 @@ parse_options() {
163163
esac
164164
done
165165

166-
if [[ $ENABLE_OIDC_IDENTITY = true && -z "$IDENTITY_USER" ]]; then
166+
if [[ $ENABLE_OIDC_IDENTITY = true && -z "$IDENTITY_USERNAME" ]]; then
167167
echo "Flag --oidc-identity must be paired with flag --identity-user. See --help."
168168
exit
169169
fi
@@ -261,10 +261,10 @@ setup_oidc_client() {
261261
}
262262

263263
function generate_identity_policy() {
264-
echo "Generating policy for AuthnOIDC V2 service 'identity' and user '$IDENTITY_USER'"
264+
echo "Generating policy for AuthnOIDC V2 service 'identity' and user '$IDENTITY_USERNAME'"
265265
policy_dir="../ci/identity"
266266
rm -f "$policy_dir/users.yml"
267-
sed -e "s#{{ IDENTITY_USER }}#$IDENTITY_USER#g" "$policy_dir/users.template.yml" > "$policy_dir/users.yml"
267+
sed -e "s#{{ IDENTITY_USERNAME }}#$IDENTITY_USERNAME#g" "$policy_dir/users.template.yml" > "$policy_dir/users.yml"
268268
}
269269

270270
check_environment_variables() {

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ require (
3333
github.com/sirupsen/logrus v1.8.1 // indirect
3434
github.com/spf13/pflag v1.0.5 // indirect
3535
github.com/zalando/go-keyring v0.2.2 // indirect
36+
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
3637
golang.org/x/sys v0.3.0 // indirect
3738
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
3839
golang.org/x/text v0.4.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ github.com/zalando/go-keyring v0.2.2 h1:f0xmpYiSrHtSNAVgwip93Cg8tuF45HJM6rHq/A5R
6363
github.com/zalando/go-keyring v0.2.2/go.mod h1:sI3evg9Wvpw3+n4SqplGSJUMwtDeROfD4nsFz4z9PG0=
6464
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
6565
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
66+
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
67+
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
6668
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
6769
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6870
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=

0 commit comments

Comments
 (0)