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

Feature/cognito webpage redirect #149

Merged
merged 54 commits into from
Dec 12, 2019
Merged

Conversation

joshmarsh
Copy link
Contributor

@joshmarsh joshmarsh commented Dec 2, 2019

Proposed changes

  • Added /auth endpoint that returns web page which redirects user to cognito/idp login page.
  • Added WithParameterStoreEnv() function to pkg/config, which retrieves environment variables from SSM Parameter Store. Credential_web_page_lambda has a runtime dependency on cognito. Cognito has a deploy time dependency on ApiGwy, and ApiGwy has a deploy time dependency on credential_web_page_lambda. Moving credential_web_page_lambda's environment variables to SSM Parameter Store breaks what would otherwise be a deploy time dependency cycle.
  • Other minor edits to pkg/config
  • Moved repetitive http response helper code to pkg/api/response

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (changes to code, which do not change application behavior)

Checklist

  • I have filled out this PR template
  • I have read the CONTRIBUTING doc
  • I have added automated tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (README.md, inline comments, etc.)
  • I have updated the CHANGELOG.md under a ## next release, with a short summary of my changes

Dependencies and Blockers

Relevant Links

Issue: Optum/dce-cli#33

Further comments

@joshmarsh joshmarsh changed the title Feature/cognito webpage redirect WIP: Feature/cognito webpage redirect Dec 2, 2019
@@ -187,68 +184,3 @@ func newAWSSession() *session.Session {
}
return awsSession
}

// WriteServerErrorWithResponse - Writes a server error with the specific message.
func WriteServerErrorWithResponse(w http.ResponseWriter, message string) {
Copy link
Contributor Author

@joshmarsh joshmarsh Dec 2, 2019

Choose a reason for hiding this comment

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

These are used by accounts, usage, and credentials_web_page, so I moved them here to be more DRY.

// response message for the API
func CreateAPIErrorResponse(responseCode int,
func CreateAPIGatewayErrorResponse(responseCode int,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to better distinguish from the ResponseWriter functions below.

@joshmarsh
Copy link
Contributor Author

/azp run dce#destroy

@joshmarsh joshmarsh changed the title [WIP] Feature/cognito webpage redirect Feature/cognito webpage redirect Dec 6, 2019
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@eschwartz
Copy link
Contributor

Sweet, taking a look now

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="/api/auth/public/amazon-cognito-auth.min.js"></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.536.0.min.js"></script>
<script src="https://unpkg.com/vue"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we actually using vue.js for this?

Copy link
Contributor Author

@joshmarsh joshmarsh Dec 10, 2019

Choose a reason for hiding this comment

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

The javascript is structured to use vuejs for convenience (i.e. data, methods, and mounted() are all vuejs constructs). I can rewrite it to not use vuejs, but it will take a bit of extra time.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, no need to take the time now.
Just something to keep in mind (probably more dependency bloat than we need for something like this)

</head>

<body>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need jQuery

Copy link
Contributor Author

@joshmarsh joshmarsh Dec 10, 2019

Choose a reason for hiding this comment

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

Apparently not, good catch.

<h1 class="center-text">DCE CLI Credentials</h1>
<button @click="copyToClipboard()" class="js-textareacopybtn center-block">Copy To Clipboard</button>
<textarea rows="10" cols="50" class="js-copytextarea center-block" id="credentialscontainer"></textarea>
<button @click="signOut()" class="center-block">Sign Out</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a newline character to the end of the token, so I don't have to hit enter when I paste it into my terminal?

@eschwartz
Copy link
Contributor

@joshmarsh this is freaking awesome.

Nice work on all this.

eschwartz
eschwartz previously approved these changes Dec 10, 2019
@joshmarsh
Copy link
Contributor Author

/azp run dce#create

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@joshmarsh
Copy link
Contributor Author

/azp run dce#destroy

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@joshmarsh joshmarsh changed the title Feature/cognito webpage redirect [Do Not Merge] Feature/cognito webpage redirect Dec 11, 2019
@joshmarsh joshmarsh changed the title [Do Not Merge] Feature/cognito webpage redirect Feature/cognito webpage redirect Dec 12, 2019
@joshmarsh
Copy link
Contributor Author

/azp run dce#destroy

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -16,7 +16,6 @@
</head>

<body>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@joshmarsh joshmarsh merged commit bf99763 into master Dec 12, 2019
@joshmarsh joshmarsh deleted the feature/cognito-webpage-redirect branch December 12, 2019 19:25
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.

2 participants