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

DXCDT-84: Resource Exclusion #468

Merged
merged 11 commits into from
Apr 1, 2022
Merged

DXCDT-84: Resource Exclusion #468

merged 11 commits into from
Apr 1, 2022

Conversation

willvedd
Copy link
Contributor

✏️ Changes

Introducing the initial implementation for resource exclusion. As proposed in #451 , this provides a mechanism for users to ignore entire resource types (organizations, connections, hooks, etc.). This mechanism functions bi-directionally and will completely omit all resources from being fetched, written to config-as-code and updating.

In practice, users will add a AUTH0_EXCLUDED property to their user-defined configuration file and list the resource types they wish to exclude from the purview of the tool.

Example:

{
  "AUTH0_DOMAIN": "test.us.auth0.com",
  "AUTH0_CLIENT_ID": "FOO",
  "AUTH0_CLIENT_SECRET": "foobarsecret",
  "AUTH0_EXCLUDED": [
    "pages",
    "organizations",
    "clients"
   ]
}

The approach here is fairly naive but effective. Not all permutations of exclusions have been tested and because of inter-dependencies between resources, exclusions may lead to unexpected behavior. But it's expected to function under the vast majority of use cases.

🔗 References

🎯 Testing

I fought with the existing unit tests and was only able to add a unit test to the Auth0 class side. This test asserts that no excluded resources get fetched or pushed to Auth0. However, I had difficulty implementing

Regardless, this being a fairly wide-reaching concept, it probably isn't appropriate to unit test. Instead, we should have a broader set of integration that can better assert the behavior of this functionality.

Regardless, plenty of manual test were done on this to confirm that this works for both YAML and directory config types, and varying permutations of this configuration.

@willvedd willvedd requested a review from adamjmcgrath March 31, 2022 21:01
@willvedd willvedd requested a review from a team as a code owner March 31, 2022 21:01
@@ -78,14 +78,17 @@ export default class DirectoryContext {
// Copy clients to be used by handlers which require converting client_id to the name
// Must copy as the client_id will be stripped if AUTH0_EXPORT_IDENTIFIERS is false
//@ts-ignore because assets haven't been typed yet TODO: type assets
this.assets.clientsOrig = [...this.assets.clients];
this.assets.clientsOrig = [...this.assets.clients || []];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clients could theoretically be excluded and thus be empty so need to default to empty array.


// Optionally Strip identifiers
if (!this.config.AUTH0_EXPORT_IDENTIFIERS) {
this.assets = stripIdentifiers(auth0, this.assets);
}

await Promise.all(Object.entries(handlers).map(async ([name, handler]) => {
await Promise.all(Object.entries(handlers).filter(([handlerName]: [AssetTypes, DirectoryHandler<any>]) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This array filter function is the primary mechanism for exclusion.

Base automatically changed from typing-Auth0-class to master April 1, 2022 15:33
@willvedd willvedd merged commit cae85e7 into master Apr 1, 2022
@willvedd willvedd deleted the DXCDT-84-resource-exclusion branch April 1, 2022 19:34
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