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

MDTZ-1461 static resource auth #211

Merged
merged 2 commits into from
Feb 12, 2024
Merged

Conversation

akostevich-atlassian
Copy link
Collaborator

@akostevich-atlassian akostevich-atlassian commented Feb 12, 2024

Changes

  • fix: Resolves the issue with the "Designs" panel not being available when a user uses the old experience due to a HTTP 401 error. Please, see the comments below for more detail.
    • Allows serving static content (e.g., HTML, CSS, etc.) with no authentication/authorization.

image

Notes

The issue is resolved by allowing serving static content (e.g., HTML, CSS, etc.) with no authentication/authorization. While the authentication has been recently introduced within #208, we might need to re-evaluate this decision for the following reasons:

  • Adding authentication and authorization to static content routes increases latency (as it adds a request to the database and Jira API).
  • Adding authentication and authorization to static content routes requires a careful route configuration (to exclude non-HTML files) and brings extra complexity.
  • Static content does not have any user data and therefore, can be served publicly.
  • Jira does not specifically handle HTTP 401 from iframes -- it looks like a generic error, so returning HTTP 401 does not bring much value to users.

Please, see the comments below for more detail.

* @see https://developer.atlassian.com/cloud/jira/platform/understanding-jwt-for-connect-apps/#types-of-jwt-token
* @see https://community.developer.atlassian.com/t/action-required-atlassian-connect-vulnerability-allows-bypass-of-app-qsh-verification-via-context-jwts/47072
*/
export const jiraIframeSymmetricJwtAuthenticationMiddleware: RequestHandler = (
Copy link
Collaborator Author

@akostevich-atlassian akostevich-atlassian Feb 12, 2024

Choose a reason for hiding this comment

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

note: Represents a replacement for the deleted jiraContextSymmetricJwtFromQueryAuthenticationMiddleware (introduced within #208) as the correct way to authenticate requests from iframes.

The new middleware uses a different verifier (jiraIframeOrServerToServerSymmetricJwtTokenVerifier instead of jiraContextSymmetricJwtFromQueryAuthenticationMiddleware) and apples minor fixes to how a request is handled.

However, the middleware is not currently used and can be safely removed if the team agrees on serving static content without authentication. However, if we decide that the authentication is required, this middleware can be used to handle this.

jiraAdminOnlyAuthorizationMiddleware,
);

staticRouter.use(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note: Currently, all requests to /static/issue-panel.html fail with HTTP 401. The issue is caused by a bug in the original jiraContextSymmetricJwtFromQueryAuthenticationMiddleware.

image

export const staticRouter = Router();

staticRouter.use(
'/admin/index.html',
Copy link
Collaborator Author

@akostevich-atlassian akostevich-atlassian Feb 12, 2024

Choose a reason for hiding this comment

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

note: The auth issue is not reproducible with the admin page. This happens since the admin page is served from /static/admin but not /static/admin/index.html (see here) therefore, and therefore, this configuration is ignored for requests from Jira.

Copy link
Collaborator

Choose a reason for hiding this comment

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

🤦🏻‍♂️ the confirmation bias in me testing this code

@Roystbeef Roystbeef merged commit de31b17 into main Feb 12, 2024
2 checks passed
@akostevich-atlassian akostevich-atlassian deleted the MDTZ-1461-static-resource-auth branch February 12, 2024 19:42
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