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 Identity support to dev environment #124

Merged
merged 7 commits into from
Apr 26, 2023
Merged

Conversation

juniortaeza
Copy link
Contributor

@juniortaeza juniortaeza commented Apr 10, 2023

Desired Outcome

This pull request adds support for Identity in the Dev Environment.

Implemented Changes

Describe how the desired outcome above has been achieved with this PR. In
particular, consider:

  • created ci/identity policy, secrets, and users file
  • refactored ./dev/start script to include Identity support
  • added user/password prompt flow to authenticate via Identity
  • added function that fetches OIDC code from Identity (mimics browser authentication)

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: [insert issue ID]
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

@juniortaeza juniortaeza requested a review from a team as a code owner April 10, 2023 17:35
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
dev/start Outdated Show resolved Hide resolved
@john-odonnell john-odonnell force-pushed the update-dev-env-branch branch 2 times, most recently from 861ee54 to d3c6ac6 Compare April 18, 2023 18:12
@john-odonnell john-odonnell force-pushed the update-dev-env-branch branch from d3c6ac6 to 6d32796 Compare April 25, 2023 17:08
Copy link
Contributor

@gl-johnson gl-johnson left a comment

Choose a reason for hiding this comment

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

Looks good, just left a couple questions. Also looks like a rebase will fix the unit tests

# Users with permission to authenticate
- !user test.user3@mycompany.com
- !user conjur_ci_user@cyberark.com
- !user conj_ops_dev@cyberark.com
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticing that these hard-coded users are the same as Okta. That may be valid depending on infra's setup, but if we are also enforcing that IDENTITY_USERNAME must be set in the environment when running dev/start, are these other users needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not at the moment - they might be introduced with future integration tests, but they can be added then. Removing.

echo "Setting up Conjur for OIDC (Identity)"
docker-compose exec cli-dev bash -c 'conjur logout
conjur init --force-netrc --force -u http://conjur -i -a dev -t oidc --service-id identity
conjur login -i $IDENTITY_USERNAME'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it assumed that a developer will be using their own account as IDENTITY_USERNAME and providing their own password?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's the idea. Feel free to to test it out, all C&I team should have Identity access now.

return authRequest[advanceAuthData, advanceAuthResponse](endpoint, data, httpClient)
}

func fetchAuthTokenFromIdentity(httpClient *http.Client, providerURL string, username string, password string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice job on this! Looks like Identity makes it tricky to automate these calls 😳

InnerExceptions string `json:"InnerExceptions"`
}

func authRequest[data startAuthData | advanceAuthData, responseContent startAuthResponse | advanceAuthResponse](
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like CodeClimate is unable to lint the file due to this square bracket notation for type contraints. As far as I can tell its valid - any idea what that's about?

Could not lint file: /code/pkg/clients/authn_oidc_dev.go
Error /code/pkg/clients/authn_oidc_dev.go:291:17: expected '(', found '[' (and 2 more errors)

Copy link
Contributor

@john-odonnell john-odonnell Apr 26, 2023

Choose a reason for hiding this comment

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

It looks like golint was frozen and deprecated in 2020, and Go introduced generics in 2022 with 1.18, so they definitely aren't supported. Maybe we should disable golint in CodeClimate, it's bound to get less and less accurate.

@john-odonnell john-odonnell force-pushed the update-dev-env-branch branch from 6d32796 to 4c42aab Compare April 26, 2023 18:14
@john-odonnell john-odonnell requested a review from a team as a code owner April 26, 2023 18:14
juniortaeza and others added 5 commits April 26, 2023 14:44
golint was frozen and deprecated in 2020. We should disable golint
on this project, as we use Go 1.19, released in 2022.

golint deprecation issue: golang/go#38968
@john-odonnell john-odonnell force-pushed the update-dev-env-branch branch from 4c42aab to 03abeeb Compare April 26, 2023 18:46
@codeclimate
Copy link

codeclimate bot commented Apr 26, 2023

Code Climate has analyzed commit 03abeeb and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 82.2% (0.0% change).

View more on Code Climate.

Copy link
Contributor

@gl-johnson gl-johnson left a comment

Choose a reason for hiding this comment

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

LGTM!

@john-odonnell john-odonnell merged commit c4fe878 into master Apr 26, 2023
@john-odonnell john-odonnell deleted the update-dev-env-branch branch April 26, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants