backstage icon indicating copy to clipboard operation
backstage copied to clipboard

πŸ™ Help Wanted: Auth Backend Module Migrations

Open Rugvip opened this issue 3 years ago β€’ 43 comments

The auth backend recently introduced a new architecture as it was migrated to support the new backend system in #19280. The new architecture implements the auth provider specific logic as "authenticators". There are currently two different kinds of authenticators, OAuth and proxy, along with accompanying route handlers and provider factories.

As part of this we also move all auth providers to be separate modules, and then use that new module for the implementation in auth-backend for backwards compatibility.

Process

For any given OAuth provider implementation, the following is a good starting point for migrating any provider:

  1. Duplicate the plugins/auth-backend-module-gitlab-provider directory to plugins/auth-backend-module-<provider-id>-provider
  2. Case sensitive search and replace all occurrences of GitLab with <ProviderName>, use the name of the provider as it appears in text.
  3. Case sensitive search and replace all occurrences of Gitlab with <ProviderId>, use the PascalCase version of the provider name as it appears in code, this might be the same as the previous step.
  4. Case sensitive search and replace all occurrences of gitlab with <providerId>, use the camelCase version of the provider name as it appears in code.
  5. Now passport strategy and any other provider-specific logic and configuration from plugins/auth-backend/src/providers/<providerId>/provider.ts. If there are tests for this specific logic then you can migrate those to authenticator or module tests, but other than that the existing provider tests can be deleted. If there are particular tests that you would like too keep, check if it makes sense to add them to https://github.com/backstage/backstage/blob/master/plugins/auth-node/src/oauth/createOAuthRouteHandlers.test.ts.
  6. Update config.d.ts in the new module, move over and remove any related configuration in plugins/auth-backend/config.d.ts.
  7. Now refactor plugins/auth-backend/src/providers/<providerId> to use the new module, adding a dependency for the new module to auth-backend. Use the legacy helpers as shown in #19475, do not add additional resolvers, options, or other API.

The process for migrating a proxy provider is similar, but use plugins/auth-backend-module-gcp-iap-provider as a starting point instead.

Migration Status

This is the current migration status of all auth providers that need migration. Let us know if you want to help out! πŸ™

  • [x] atlassian #21007
  • [x] auth0 #26421
  • [x] aws-alb #22103
  • [x] azure-easyauth #23909
  • [x] bitbucket #24287
  • [x] bitbucketServer #26407
  • [x] cloudflare-access #23997
  • [x] gcp-iap #19280
  • [x] github #19473
  • [x] gitlab #19475
  • [x] google #19280
  • [x] microsoft #20120 #22208
  • [x] oauth2 #19696
  • [x] oauth2-proxy #20685
  • [x] oidc #20282
  • [x] okta #21325
  • [x] onelogin #24353
  • [x] pinniped #19846
  • [x] VMware Cloud #21337

Rugvip avatar Aug 21 '23 08:08 Rugvip

Hi @Rugvip I'd like to help out

mihrab34 avatar Aug 21 '23 17:08 mihrab34

Hello @Rugvip I'd also want to help

IvyJeptoo avatar Aug 21 '23 20:08 IvyJeptoo

@mihrab34 @IvyJeptoo great! πŸŽ‰ Best pick a single provider to start with

Rugvip avatar Aug 22 '23 08:08 Rugvip

@Rugvip I'm having this error when i try yarn install after forking & cloning the project

yarn install error

mihrab34 avatar Aug 24 '23 12:08 mihrab34

@Rugvip, can we put a hold on the Microsoft auth provider? I'm wondering if now is a good time to rename it. We use Azure in most places and this is one of the only places we call something Microsoft (that I'm aware of could be wrong). I can put together an RFC to get feedback on this if you think that's needed. CC @sanderaernouts @afscrome

awanlin avatar Aug 24 '23 12:08 awanlin

@awanlin yep we could easily do a rename when creating the new module πŸ‘ Let's not ship any new module before we have settled on the name.

I'd say though that from my understanding "Microsoft" actually makes sense. I find it to be similar to Google auth, where the auth itself if managed through GCP and gives access to a lot of GCP resources, but the scope in the end is much broader than just GCP, so it's the "Google" provider.

Rugvip avatar Aug 24 '23 13:08 Rugvip

@mihrab34 seems like there's an issue with the isolated-vm installation, most likely you'll want to have a look at https://github.com/laverdet/isolated-vm#requirements and make sure that's covered for your OS

Rugvip avatar Aug 24 '23 13:08 Rugvip

@awanlin @Rugvip I'm happy to spend some time doing the Microsoft provider, I think we should keep it as Microsoft, purely because they're rolling Azure AD into Entra ID in the coming months AFAIK

TheGemmell avatar Aug 24 '23 13:08 TheGemmell

@awanlin A month of two ago, I'd definitely have said to rename to azure, however Microsoft have now decided to rename Azure Active Directory to Microsoft Entra Id 🀦 https://devblogs.microsoft.com/identity/aad-rebrand

I do think the Microsoft / Azure integrations as a whole could do with a naming check as there are a few naming inconsistencies. (e.g. some of the Azure Devops integrations are just named azure, even though ADO is separate to Azure).

afscrome avatar Aug 24 '23 13:08 afscrome

Alright, that works for me, also forgot about the whole name change for Azure AD. Then feel free to work on this who every wants!

Thanks for the feedback @Rugvip @TheGemmell @afscrome πŸ‘

awanlin avatar Aug 24 '23 14:08 awanlin

@Rugvip I just wanted to ask if it possible if we can mention the modules that each will be handling so that two people dont work on the same module(just a suggestion)

IvyJeptoo avatar Aug 24 '23 16:08 IvyJeptoo

@IvyJeptoo yep makes sense, done

Rugvip avatar Aug 27 '23 14:08 Rugvip

I'll be running with oauth2 as this is something we need internally πŸ‘

awanlin avatar Aug 28 '23 16:08 awanlin

@Rugvip I opened a PR for bitbucket on #19665

mihrab34 avatar Aug 30 '23 08:08 mihrab34

I will take the auth0

ekafeel avatar Aug 30 '23 09:08 ekafeel

PR for the oauth2 provider is here: https://github.com/backstage/backstage/pull/19696

awanlin avatar Aug 31 '23 13:08 awanlin

I will be working on the oidc migration

RubenV-dev avatar Sep 07 '23 20:09 RubenV-dev

@TheGemmell what’s the ETA on the Microsoft auth module? This is blocking us from using the new backend system

ahhhndre avatar Sep 22 '23 21:09 ahhhndre

@ahhhndre Apologies, I actually finished the code changes, then had to go on leave for an emergency. Got back and had forgotten about it. I'll test and raise a PR by end of the weekend

TheGemmell avatar Sep 23 '23 01:09 TheGemmell

PR for microsoft provider is here: #20120

TheGemmell avatar Sep 23 '23 05:09 TheGemmell