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

[Auth] Migrate app-backend to use new auth services #23719

Merged
merged 36 commits into from Apr 9, 2024
Merged

Conversation

camilaibs
Copy link
Contributor

@camilaibs camilaibs commented Mar 20, 2024

Hey, I just made a Pull Request!

Migrate app-backend to use new auth APIs:

  • Cookie refresh
    • Backend endpoint, /.backstage/v1-cookie
    • Frontend provider
  • Remove issueUserCookie from HttpAuthService and move to auth-node
  • Move RedirectToRoot to auth-react
  • Logout? How do we clear the cookie?
  • Document index-public-experimental & how to use

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@github-actions github-actions bot added auth area:techdocs Related to the TechDocs Project Area labels Mar 20, 2024
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Mar 20, 2024

Changed Packages

Package Name Package Path Changeset Bump Current Version
example-app packages/app none v0.2.96-next.0
@backstage/backend-app-api packages/backend-app-api patch v0.6.3-next.0
@backstage/backend-plugin-api packages/backend-plugin-api patch v0.6.17-next.0
@backstage/cli packages/cli patch v0.26.3-next.0
@backstage/core-app-api packages/core-app-api patch v1.12.3
@backstage/frontend-app-api packages/frontend-app-api patch v0.6.4-next.0
@backstage/plugin-app-backend plugins/app-backend patch v0.3.65-next.0
@backstage/plugin-auth-react plugins/auth-react minor v0.0.4-next.0
@backstage/plugin-techdocs-backend plugins/techdocs-backend patch v1.10.4-next.0

Copy link
Contributor

github-actions bot commented Mar 20, 2024

Uffizzi Cluster pr-23719 was deleted.

@camilaibs camilaibs force-pushed the rugvip/app-auth branch 12 times, most recently from e744c99 to 0224cfe Compare March 21, 2024 15:18
@github-actions github-actions bot added documentation Improvements or additions to documentation microsite Changes to backstage.io labels Mar 21, 2024
<OAuthRequestDialog />
<AppRouter>
{/* For now, this is just a temporary solution to ensure the user remains logged in properly and has access to the main app content. */}
<ExperimentalAppProtection>
Copy link
Contributor Author

@camilaibs camilaibs Mar 21, 2024

Choose a reason for hiding this comment

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

This seems unnecessary to do manually, I would have placed it in the createRoot logic, but we can't have a dependency on the auth-react package from the core-app-api package, can we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The public path is not going to work, inject the mode instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Convert to an element instead of using a wrap.

Copy link
Contributor Author

@camilaibs camilaibs Apr 4, 2024

Choose a reason for hiding this comment

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

I realised that the cookie refresh provider expects children, so it needs to be a wrap because of that.

@camilaibs camilaibs marked this pull request as ready for review March 22, 2024 10:58
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
… AppIdentityProxy

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
… example

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

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

Mkay should be ready to go now 🤞

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
plugins/app-backend/src/service/router.ts Outdated Show resolved Hide resolved
plugins/app-backend/src/service/router.ts Outdated Show resolved Hide resolved
exports.down = async function down(knex) {
await knex.schema.alterTable('static_assets_cache', table => {
table.dropIndex([], 'static_asset_cache_namespace_idx');
table.dropColumn('namespace');
Copy link
Member

Choose a reason for hiding this comment

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

can you do these in the same transaction 🤔 maybe

plugins/app-backend/src/service/router.ts Show resolved Hide resolved
const injectedConfigPath =
appConfigs && (await injectConfig({ appConfigs, logger, staticDir }));

await injectAppMode({ appMode, rootDir });
Copy link
Member

Choose a reason for hiding this comment

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

Just noting that our disableConfigInjection was there to cover readonly filesystems, and now this one also does writes - do we have to honor that flag for this purpose too?

Also, is it really not possible to do "live" injection of stuff in our app backend serving code? Even with like a middleware, that mutates the body before getting sent?

Copy link
Member

Choose a reason for hiding this comment

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

We had a live one but switched to this for simplicity, since that one needs to handle a couple of different cases. We could tweak the injection to only happen if it's not needed, but tbh I prefer the approach of adding it on the fly. Gonna leave that for a followup though

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
…lic bundle

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
@Rugvip Rugvip enabled auto-merge April 9, 2024 15:21
@Rugvip Rugvip disabled auto-merge April 9, 2024 15:45
@Rugvip Rugvip merged commit df279de into master Apr 9, 2024
44 checks passed
@Rugvip Rugvip deleted the rugvip/app-auth branch April 9, 2024 15:45
Copy link
Contributor

github-actions bot commented Apr 9, 2024

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.26.0 release, scheduled for Tue, 14 May 2024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:techdocs Related to the TechDocs Project Area auth documentation Improvements or additions to documentation microsite Changes to backstage.io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants