-
Notifications
You must be signed in to change notification settings - Fork 65
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: Allow AEM CLI to obtain site token #2471
base: main
Are you sure you want to change the base?
Conversation
This PR will trigger a minor release when merged. |
.withOrg(org) | ||
.withSiteLoginUrl( | ||
// TODO switch to production URL | ||
`https://admin-ci.hlx.page/login/${org}/${site}/main?client_id=aem-cli&redirect_uri=${encodeURIComponent(`http://localhost:${this._httpPort}/.aem/cli/login/ack`)}`, |
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.
Reminder to switch to the production admin url, before merging.
on the one hand, I think updating gitignore as mentioned in step 7 is enough.... |
Sounds good to me, we can put it The only small concern I have is that LE: Done in 4ae5777. |
Changes:
2.1. Automatically: the proxy in the CLI notices a
401
or403
response during navigation and redirects the user to Helix Admin for login. This is done only once per CLI execution.2.2. Manually(User Friendly): If for some reason the automatic way didn't work, the user will have the opportunity to initiate the login flow every time a
401
or403
error page is being displayed, as they include a link.2.3. Manually(Forced): going to
/.aem/cli/login
will immediately start the login flow.3.1 The path is the site where we want to login on the main branch
https://admin.hlx.page/login/{org}/site}/main
. The org and site are extracted from the proxied url.3.2 There is a query parameter for letting Helix Admin know this is the
aem-cli
(client_id=aem-cli
)3.3. There is a redirect uri parameter for letting Helix Admin know where the cli runs and waits for a response (
redirect_uri=http://localhost:3000/.aem/cli/login/ack
- only the port can vary)3.4 There is a state parameter generated by the CLI and returned by Helix Admin as-is, so the CLI can know that the token it received corresponds to a login flow that was initiated by it.
4.1 it will send a POST request to the ACK endpoint with the transient site token and the state.
4.2 redirect the browser to the same ACK endpoint, when the POST request is finished.
.env
file only if the state matches what it sent at the beginning of the login flow, otherwise it will discard it.6.1. redirect to
/
if everything was successful6.2 display an error corresponding to what went wrong during the login flow.
.env
file is ignored by git and add it to the.gitignore
file otherwise, to prevent tokens from being stored in version control.