roadie-backstage-plugins icon indicating copy to clipboard operation
roadie-backstage-plugins copied to clipboard

feat(plugins/backend/okta): migrate to new backend system

Open secustor opened this issue 10 months ago • 3 comments

:heavy_check_mark: Checklist

  • [ ] Added tests for new functionality and regression tests for bug fixes
  • [x] Added changeset (run yarn changeset in the root)
  • [ ] Screenshots of before and after attached (for UI changes)
  • [x] Added or updated documentation (if applicable)

secustor avatar Apr 09 '24 10:04 secustor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

github-actions[bot] avatar Apr 18 '24 11:04 github-actions[bot]

@kissmikijr any timeline on when this will be reviewed, I am waiting for this change to test in the new backend system.

Nirmalkumar9182 avatar Apr 22 '24 03:04 Nirmalkumar9182

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

github-actions[bot] avatar Apr 29 '24 03:04 github-actions[bot]

@kissmikijr I believe this should be a valid PR, is this closed accidentally closed.

Nirmalkumar9182 avatar May 06 '24 02:05 Nirmalkumar9182

@secustor Should this be reopned

Nirmalkumar9182 avatar May 06 '24 02:05 Nirmalkumar9182

Yes, should be reopended if there is an interest to accept this.

secustor avatar May 06 '24 06:05 secustor

After this update, i am not able to get the user and group list from okta after update, always getting 0 users.

logs:

1] 2024-05-27T09:40:20.326Z catalog info Providing user and group resources from okta 
[1] 2024-05-27T09:40:20.326Z catalog info Found 0, pruning the empty ones 
[1] 2024-05-27T09:40:20.327Z catalog info Finished providing 0 user and 0 group resources from okta 

code changes

const oktaCatalogBackendModule = createBackendModule({
  pluginId: 'catalog',
  moduleId: 'okta-entity-provider-custom',
  register(env) {
    env.registerInit({
      deps: {
        catalogModel: catalogModelExtensionPoint,
        provider: oktaCatalogBackendEntityProviderFactoryExtensionPoint,
        logger: coreServices.logger,
      },
      async init({ provider, logger }) {
        const factory: EntityProviderFactory = (oktaConfig: Config) =>
          OktaOrgEntityProvider.fromConfig(oktaConfig, {
            logger: loggerToWinstonLogger(logger),
            userNamingStrategy: 'strip-domain-email',
            groupNamingStrategy: 'kebab-case-name',
            userTransformer: oktaUserTransformer,
          });

        provider.setEntityProviderFactory(factory);
      },
    });
  },
});

Config:

catalog:
  providers:
    okta:
      - orgUrl: 
          $env: AUTH_OKTA_API_DOMAIN
        token: 
          $env: AUTH_OKTA_TOKEN
        groupFilter: profile.name eq "aws-cde-plat-engr" or profile.name eq "aws-dpe-digital-platform"
        userFilter: profile.department eq "ENGINEERING" and status eq "ACTIVE"
        frequency: 
          minutes: 5
        timeout:
          minutes: 5

and the package version i am using "@roadiehq/catalog-backend-module-okta": "^0.10.0", anyone else facing this or i am doing something wrong.

Nirmalkumar9182 avatar May 27 '24 05:05 Nirmalkumar9182

After this update, i am not able to get the user and group list from okta after update, always getting 0 users.

logs:

1] 2024-05-27T09:40:20.326Z catalog info Providing user and group resources from okta 
[1] 2024-05-27T09:40:20.326Z catalog info Found 0, pruning the empty ones 
[1] 2024-05-27T09:40:20.327Z catalog info Finished providing 0 user and 0 group resources from okta 

code changes

const oktaCatalogBackendModule = createBackendModule({
  pluginId: 'catalog',
  moduleId: 'okta-entity-provider-custom',
  register(env) {
    env.registerInit({
      deps: {
        catalogModel: catalogModelExtensionPoint,
        provider: oktaCatalogBackendEntityProviderFactoryExtensionPoint,
        logger: coreServices.logger,
      },
      async init({ provider, logger }) {
        const factory: EntityProviderFactory = (oktaConfig: Config) =>
          OktaOrgEntityProvider.fromConfig(oktaConfig, {
            logger: loggerToWinstonLogger(logger),
            userNamingStrategy: 'strip-domain-email',
            groupNamingStrategy: 'kebab-case-name',
            userTransformer: oktaUserTransformer,
          });

        provider.setEntityProviderFactory(factory);
      },
    });
  },
});

Config:

catalog:
  providers:
    okta:
      - orgUrl: 
          $env: AUTH_OKTA_API_DOMAIN
        token: 
          $env: AUTH_OKTA_TOKEN
        groupFilter: profile.name eq "aws-cde-plat-engr" or profile.name eq "aws-dpe-digital-platform"
        userFilter: profile.department eq "ENGINEERING" and status eq "ACTIVE"
        frequency: 
          minutes: 5
        timeout:
          minutes: 5

and the package version i am using "@roadiehq/catalog-backend-module-okta": "^0.10.0", anyone else facing this or i am doing something wrong.

Aftyer some debugging found the issue https://github.com/RoadieHQ/roadie-backstage-plugins/blob/47dfad2f3ca60ce6f2b46177acc3b6038fbca064/plugins/backend/catalog-backend-module-okta/src/providers/OktaOrgEntityProvider.ts#L78C5-L80C31 the way the account details are retrieved is not working in the new code as its not passing in the whole config its only passing in the okta config

My Updated as work around

const oktaCatalogBackendModule = createBackendModule({
  pluginId: 'catalog',
  moduleId: 'okta-entity-provider-custom',
  register(env) {
    env.registerInit({
      deps: {
        provider: oktaCatalogBackendEntityProviderFactoryExtensionPoint,
        logger: coreServices.logger,
      },
      async init({ provider, logger }) {
        const orgProvider: EntityProviderFactory = (config: Config) => {
          const account: AccountConfig = {
            orgUrl: config.getOptional('orgUrl') || '',
            token: config.getOptional('token') || '',
            oauth: config.getOptional('oauth'),
            userFilter: config.getOptional('userFilter') || '',
            groupFilter: config.getOptional('groupFilter') || '',
          };
          // creating the account manually as the way the config is red in the plugin is not working for the new backend module
          return new OktaOrgEntityProvider([account], {
            logger: loggerToWinstonLogger(logger),
            userNamingStrategy: 'strip-domain-email',
            groupNamingStrategy: 'kebab-case-name',
            userTransformer: oktaUserTransformer,
          });
        };
        provider.setEntityProviderFactory(orgProvider);
      },
    });
  },
});

cc @secustor

Nirmalkumar9182 avatar May 28 '24 09:05 Nirmalkumar9182