-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat(ui): Make it easy to use SSO login with CLI. Resolves #4630 #4645
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9a1168b
feat(ui): Make it easy to use SSO login with CLI. Resolves #4630
alexec d026a48
fix-4630: M ui/src/app/userinfo/components/cli-help.tsx
alexec e692e62
Merge branch 'master' into fix-4630
alexec c9d41a9
Merge branch 'master' into fix-4630
alexec 175db3c
Merge branch 'master' into fix-4630
alexec File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as React from 'react'; | ||
import {createRef, useState} from 'react'; | ||
|
||
export const CliHelp = () => { | ||
const argoSecure = document.location.protocol === 'https'; | ||
const argoBaseHref = document | ||
.getElementsByTagName('base')[0] | ||
.href.toString() | ||
.replace(document.location.protocol + '//' + document.location.host + '/', ''); | ||
const argoToken = decodeURIComponent(document.cookie) | ||
.split(';') | ||
.map(x => x.trim()) | ||
.find(x => x.startsWith('authorization=')) | ||
.replace('authorization=', ''); | ||
|
||
const text = `export ARGO_SERVER='${document.location.host}' | ||
export ARGO_HTTP1=true | ||
export ARGO_SECURE=${argoSecure ? 'true' : 'false'} | ||
export ARGO_BASE_HREF=${argoBaseHref} | ||
export ARGO_TOKEN='${argoToken}' | ||
export ARGO_NAMESPACE=argo ;# or whatever your namespace is | ||
export KUBECONFIG=/dev/null ;# recommended | ||
|
||
# check it works: | ||
argo list`; | ||
|
||
const [copied, setCopied] = useState(false); | ||
const hiddenText = createRef<HTMLTextAreaElement>(); | ||
return ( | ||
<div className='white-box'> | ||
<h4>Using Your Login With The CLI</h4> | ||
<p>Download the latest CLI before you start.</p> | ||
<div style={{fontFamily: 'monospace', whiteSpace: 'pre', margin: 20}}>{text.replace(argoToken, '[REDACTED]')}</div> | ||
<p>For help with options such as ARGO_INSECURE_SKIP_VERIFY, ARGO_NAMESPACE and ARGO_INSTANCEID, run: `argo --help`.</p> | ||
<div> | ||
<button | ||
className='argo-button argo-button--base-o' | ||
disabled={copied} | ||
onClick={() => { | ||
const x = hiddenText.current; | ||
x.select(); | ||
x.setSelectionRange(0, 99999); | ||
document.execCommand('copy'); | ||
setCopied(true); | ||
}}> | ||
{copied ? ( | ||
<> | ||
<i className='fa fa-check' /> Copied to clipboard | ||
</> | ||
) : ( | ||
<> | ||
<i className='fa fa-copy' /> Copy to clipboard | ||
</> | ||
)} | ||
</button> | ||
</div> | ||
<textarea ref={hiddenText} style={{width: 0, height: 0, opacity: 0}}> | ||
{text} | ||
</textarea> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we redact the ARGO_TOKEN here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply redact it on the original string? It seems
argoToken
is not used anywhere except to get redactedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it made it simpler to have a single un-redacted const than two const