-
Notifications
You must be signed in to change notification settings - Fork 193
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
Arc 1456 auto app creation #1401
Conversation
ghe-app-manifest.template.json
Outdated
@@ -0,0 +1,34 @@ | |||
{ | |||
"name": "ghe-app-for-jira", |
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 probably want this to be an empty string right? Otherwise this will auto-fill the input for every customer which they will then have to delete.
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.
@rachellerathbone, don't we want to give any relevant default name?
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.
it's not a bad idea, however, something to consider is that the name has to be unique per server...
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.
Caught up with Jade on this one and she agrees it should be blank. From a UX standpoint, we'd only pre-populate an input field if it wasn't clear what a user is meant to enter. However, is this case, app name is pretty straightforward. Plus, to @mboudreau's point: GH app names need to be unique per server so they second a customer tries to create a second app, this would fail.
Just out of curiosity, what happens when you try and add an existing app name in the input? Guessing GH renders some kind of error but want to be sure.
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.
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.
Interestingly you can proceed without giving app name and will eventually fails when trying to complete app manifest flow. Not sure issue with specific version of GH Enterprise.
Can you add a video recording of the implementation now that you've included the whole flow (from clicking 'create' on auto/manual through to the redirect screen). |
@@ -0,0 +1,15 @@ | |||
<!doctype html> |
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.
This temporary page is created to test the flow. Actual page will be developed as part of another ticket.
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.
I'd suggest to add test cases for the new routes.
installationId: installation.id | ||
}); | ||
req.session.temp = undefined; | ||
res.json({ success:true }); |
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.
Need to render app installation page which is part of another ticket and is in progress.
import { Installation } from "~/src/models/installation"; | ||
|
||
export const GithubManifestCompleteGet = async (req: Request, res: Response) => { | ||
const uuid = req.params.uuid; |
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.
where is this coming from?
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.
This is coming from redirect_url
where UUID
is part of path parameter.
"redirect_url": "<<APP_HOST>>/github/manifest/<<UUID>>/complete"
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.
maybe we can put both uuid and gheHost in the session cookie, as sessio cookie is signed cannot be tempered.
@@ -0,0 +1,22 @@ | |||
const params = new URLSearchParams(window.location.search.substring(1)); | |||
const gheHost = params.get("serverUrl"); |
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.
Where are we passing this as a param? In jira-server-url.js
it looks like we're setting customData
to an empty object if no app exists const customData = data.appExists ? { serverUrl: gheServerURL } : {};
so from empty state we're never passing this value to the URL. And then in github-app-creation.js
the only thing we're pulling from params is the jiraHost. So my guess here is that gheHost
will be null.
We need to fix this and also add error handling in the event there isn't a gheHost.
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.
You are correct @rachellerathbone. I discussed with @krazziekay, he already worked on it and serverUrl
will be available in URL once his PR gets merged.
ghe-app-manifest.template.json
Outdated
"redirect_url": "<<APP_HOST>>/github/manifest/<<UUID>>/complete", | ||
"hook_attributes": { | ||
"url": "<<APP_HOST>>/github/<<UUID>>/events" | ||
}, | ||
"setup_url": "<<APP_HOST>>/github/<<UUID>>/setup", |
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.
Can you explain the flow here? UUID is setup beforehand but the app is not installed yet, so what's the point of having the UUID there?
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.
Also, keep in mind that we might use this app manifest for our own dev flow. As might want to keep it a bit more abstracted?
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.
The flow is. : -
- Construct JSON for GitHub app
- Submit JSON data to GitHub Enterprise
- GitHub Enterpise redirected back to
redirect_url
with code which is supplied as JSON data - Exchage code with GitHub Enterprise
- Save data to
GitHubServerApps
table
When we're submitting data to GH Enterprise in step 2, we need to construct setup_url
, webhook_url
and others with UUID.
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.
@mboudreau do you have thoughts on how we should handle the url value here? This is required and is meant to link to the apps homepage. However, we don't have the app name at this point (even if we prepopulate, people can edit it). The best I can see us doing is entering <<APP_HOST>>/apps/
and adding messaging somewhere in the auto flow to let customers know they will need to update this in their settings manually?
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.
Maybe we should get together on this, but my understanding is that we shouldn't create any apps on our end until the github flow is done, which will provide us with everything we need to create the app in our DB. Creating the app beforehand means that the process might not finish and we'll have apps that were never created...
temp?: { | ||
[key: string]: any; | ||
} |
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.
Can you explain this addition and why it's needed?
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.
I need to store GHE Host
in session that can be fetched when user redirect back to redirect_url
from GitHub Enterprise.
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.
a few issues that needs addressing
ghe-app-manifest.template.json
Outdated
@@ -0,0 +1,34 @@ | |||
{ | |||
"name": "ghe-app-for-jira", | |||
"url": "https://github.com/marketplace/jira-software-github", |
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.
@rachellerathbone, what should be the URL for GHE app? Right now, I'm using the cloud app URL here.
import { Installation } from "~/src/models/installation"; | ||
|
||
export const GithubManifestCompleteGet = async (req: Request, res: Response) => { | ||
const uuid = req.params.uuid; |
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.
This is coming from redirect_url
where UUID
is part of path parameter.
"redirect_url": "<<APP_HOST>>/github/manifest/<<UUID>>/complete"
temp?: { | ||
[key: string]: any; | ||
} |
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.
I need to store GHE Host
in session that can be fetched when user redirect back to redirect_url
from GitHub Enterprise.
ghe-app-manifest.template.json
Outdated
"redirect_url": "<<APP_HOST>>/github/manifest/<<UUID>>/complete", | ||
"hook_attributes": { | ||
"url": "<<APP_HOST>>/github/<<UUID>>/events" | ||
}, | ||
"setup_url": "<<APP_HOST>>/github/<<UUID>>/setup", |
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.
The flow is. : -
- Construct JSON for GitHub app
- Submit JSON data to GitHub Enterprise
- GitHub Enterpise redirected back to
redirect_url
with code which is supplied as JSON data - Exchage code with GitHub Enterprise
- Save data to
GitHubServerApps
table
When we're submitting data to GH Enterprise in step 2, we need to construct setup_url
, webhook_url
and others with UUID.
@@ -0,0 +1,22 @@ | |||
const params = new URLSearchParams(window.location.search.substring(1)); | |||
const gheHost = params.get("serverUrl"); |
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.
You are correct @rachellerathbone. I discussed with @krazziekay, he already worked on it and serverUrl
will be available in URL once his PR gets merged.
ghe-app-manifest.template.json
Outdated
@@ -0,0 +1,34 @@ | |||
{ | |||
"name": "ghe-app-for-jira", |
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.
ghe-app-manifest.template.json
Outdated
@@ -0,0 +1,34 @@ | |||
{ | |||
"name": "ghe-app-for-jira", |
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.
Interestingly you can proceed without giving app name and will eventually fails when trying to complete app manifest flow. Not sure issue with specific version of GH Enterprise.
import { Installation } from "~/src/models/installation"; | ||
|
||
export const GithubManifestCompleteGet = async (req: Request, res: Response) => { | ||
const uuid = req.params.uuid; |
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.
maybe we can put both uuid and gheHost in the session cookie, as sessio cookie is signed cannot be tempered.
What's in this PR?
Automatic app creation has been implemented using App manifest flow.
Sequence diagram
Video demonstrating the feature
Screen.Recording.2022-07-25.at.4.07.55.pm.mov
Why
This is one of the options to create GitHub app for enterpise
Added feature flags
Existing flag
GHE_SERVER
Affected issues
ARC-1456
How has this been tested?
Unit test cases added for new routes