Skip to content

feat: Add config-manager push authz-policies command - #83

Open
dallinjsevy wants to merge 3 commits into
mainfrom
feature/config-manager-push-authz-policies
Open

feat: Add config-manager push authz-policies command#83
dallinjsevy wants to merge 3 commits into
mainfrom
feature/config-manager-push-authz-policies

Conversation

@dallinjsevy

Copy link
Copy Markdown

No description provided.

@dallinjsevy
dallinjsevy force-pushed the feature/config-manager-push-authz-policies branch from d6fc273 to 5c4344d Compare March 25, 2026 22:23
@phalestrivir
phalestrivir force-pushed the feature/config-manager-push-authz-policies branch from 5c4344d to 8c46fde Compare April 6, 2026 14:39

@phalestrivir phalestrivir left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See comments below.

Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment thread src/configManagerOps/FrConfigAuthzPoliciesOps.ts Outdated
Comment thread src/configManagerOps/FrConfigAuthzPoliciesOps.ts Outdated
Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment thread test/e2e/config-manager-push-authz-policies.e2e.test.js
Comment thread test/e2e/config-manager-push-authz-policies.e2e.test.js Outdated
@phalestrivir
phalestrivir force-pushed the feature/config-manager-push-authz-policies branch from 8c46fde to 15f3f74 Compare April 6, 2026 17:03
@dallinjsevy
dallinjsevy force-pushed the feature/config-manager-push-authz-policies branch 2 times, most recently from a83440c to 062a70e Compare April 10, 2026 15:59
@dallinjsevy
dallinjsevy force-pushed the feature/config-manager-push-authz-policies branch from 062a70e to e417383 Compare May 28, 2026 15:32

const deploymentTypes = [
CLOUD_DEPLOYMENT_TYPE_KEY,
FORGEOPS_DEPLOYMENT_TYPE_KEY,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No need to specify deployment types in this file, all deployments support authz policies, including in fr config manager (see https://github.com/ForgeRock/fr-config-manager/blob/e777695e00a4e92f3bc9f3961f21c8a66f9a6d3c/packages/fr-config-common/src/constants.js#L85-L139)

Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment thread src/configManagerOps/FrConfigAuthzPoliciesOps.ts Outdated
Comment thread src/cli/config-manager/config-manager-push/config-manager-push-authz-policies.ts Outdated
Comment on lines +250 to +254
const realmsDir = getFilePath('realms/');
realmsToProcess = fs
.readdirSync(realmsDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We have a problem here. When I do an export with Forgeops, it looks like this:

Image

Basically, the root realm is problematic. It will think "authorization" is a realm, when it isn't. I think we'll need to fix the pull command to, when it exports from root realm, to save it into a directory called root. The other thing is that authz-policies are supported in the Cloud root realm as well, so this isn't deployment specific, it applies to all of them.

The root directory should be named root, and then realms like alpha and bravo can be named as they usually are. Then, when you read in the realms, just make sure that for root you are setting it to / since root is not actually the name of it, / is.

Comment thread src/configManagerOps/FrConfigAuthzPoliciesOps.ts Outdated

@phalestrivir phalestrivir left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I noticed when going through this PR again that the way that authz policies pull was originally implemented is very wrong to begin with. Currently Brycen is doing some refactoring to fix it, so I'm thinking you wait until his changes get merged in before continuing on this PR since the exports are not entirely correct.

Once that's done, here are a few other things to do in addition to my other comments that I left:

  1. For the test data that you are using, please use the config from https://git.trivir.com/projects/TRIVIR/repos/frodo-forgeops-test-config, as it has config for each realm. Your tests are only testing the alpha realm at the moment, but there is test config for testing the root realm as well.
  2. Delete the old test mocks, there are multiple mocks that are committed that need to be deleted.
  3. Make sure you are running npm lint:fix after you make any changes since there are some formatting issues

Comment on lines +19 to +24
.addOption(
new Option(
'-n, --policy-name <set-name>',
'Policy set name. If specified, only the policy set with the specified name is imported.'
)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I just checked against fr-config-manager, and they don't actually have a -n flag for their fr-config-push command, so I think we remove it from our implementation as well.

const getTokensIsSuccessful = await getTokens();
if (!getTokensIsSuccessful) process.exit(1);
printMessage(
`Importing organization privileges config for authz policies`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This message is not importing organization privileges, it should just say something like Importing authorization policies...

Comment on lines 96 to 97
!configFileData[state.getRealm()] ||
!configFileData[state.getRealm()].includes(ps.name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would replace state.getRealm() in both these lines with a variable, which is set before as const realmDir = state.getRealm() === '/' ? 'root' : state.getRealm();, this way the configuration file can specify "root" as a realm instead of calling it "/", I think it should match the directory names where it's saved. You can set the variable before the if (configFile) since we'll be using it again when we save the config


/**
* Import authz policy sets
* @param name optional name to import

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Delete name param

* @returns {Promise<boolean>} true if all imports were successful
*/
export async function configManagerImportAuthzPolicies(
name: string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Delete name param

/*
// ForgeOps
FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://nightly.gcp.forgeops.com/am frodo config-manager push authz-policies -D test/e2e/exports/fr-config-manager/forgeops -m forgeops
FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://nightly.gcp.forgeops.com/am frodo config-manager push authz-policies -n test_id -D test/e2e/exports/fr-config-manager/forgeops -m forgeops

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Delete this test

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.

2 participants