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

Change client grants filenames with directory structure #459

Closed
ebusi opened this issue Mar 28, 2022 · 8 comments
Closed

Change client grants filenames with directory structure #459

ebusi opened this issue Mar 28, 2022 · 8 comments

Comments

@ebusi
Copy link

ebusi commented Mar 28, 2022

Describe the problem you'd like to have solved

I'm exporting Auth0 Configurations with the directory structure and have multiple tenant with the same codebase.
Inside the "grants" directory the file name contains information about the audience which is related to the tenant making it hard to use a VCS with multi tenants.

Describe the ideal solution

I think having a single file (grants.json) with an array of grants can solve this issue because you can then make use of the "keyword replace mapping" functionality to handle tenant-related values.

Alternatives and current work-arounds

No idea. Using yaml export can solves this issue but makes it really hard to handle exports because #328

@willvedd
Copy link
Contributor

willvedd commented May 6, 2022

This is an interesting problem to solve. You're correct about tenant-specific data existing in the exported configuration files. Given a multi-tenant dealing with hypothetical tenants A and B, do you think it would be appropriate to dynamically swap out the audience value's domain from tenant A with tenant B's domain? My hunch is that it would work in most cases but perhaps not all; might be a bit too clever.

I think this is something that should be natively handled by the tool and not addressed with the keyword replace mappings.

I'd like to noodle on this one a bit more, admittedly I need to familiarize myself with some of the edge cases that might present in this situation. Please let me know if you've had any additional thoughts on this.

@ebusi
Copy link
Author

ebusi commented May 17, 2022

Correct me if I'm wrong. What you are suggesting is to replace the value of the audience field with the "friendly name", the same way the client_id is now the client name. This way you can use the same audience name in every tenant.

@willvedd
Copy link
Contributor

Consider the following exported configuration:

clientGrants:
  - client_id: Deploy CLI Application
    audience: https://test-app.us.auth0.com/api/v2/
    scope:
      - read:client_grants
      - create:client_grants
      - delete:client_grants
      - update:client_grants

The audience here is hardcoded with the tenant domain. When you attempt to apply this configuration to another tenant, it will fail with the error: Not Found: No resource with identifier https://test-app.us.auth0.com/api/v2/. What I'm suggesting is dynamically detect replace these audiences with the target domains.

Related, I stumbled upon a guide in the official docs on how to navigate this specific situation. Like you guessed, it recommends leveraging the keyword replacement, which is fine, but I'm optimistic that there's some sort of smarter mechanism for this.

@ebusi
Copy link
Author

ebusi commented May 23, 2022

I just want to point I was mainly struggling with the directory export not the yaml in particular with the file name generated in the grants directory.
Following your last example, with the directory structure you end up having a grants/Deploy CLI Application (https---test-app.us.auth0.com-api-v2-).json file.
To workaround this issue I made a fork and changed the parse and dump methods to expect a single grants/grants.json file. Now I can easily take advantage of the keyword replacement and have something like this:

[
  {
    "client_id": "Deploy CLI Application",
    "audience": "https://##AUTH0_DOMAIN##/api/v2/",
    "scope": [
      "read:client_grants",
      "create:client_grants",
      "delete:client_grants",
      "update:client_grants"
    ]
  }
]

As you stated previously I'm not sure this is the best solution but for my use case it works.

@willvedd
Copy link
Contributor

@ebusi Ah! Ok I see what you mean now. I agree the filename is problematic and don't see any reason why we couldn't exclude the audience value. For the above example, if the generated client grant file name was grants/Deploy CLI Application.json instead, that would satisfy the original complaint, correct?

@ebusi
Copy link
Author

ebusi commented May 26, 2022

Yup. That should work.

@willvedd
Copy link
Contributor

willvedd commented Feb 7, 2023

@ebusi We actually introduced a "fix" for this but didn't account for the cases where a single client would have multiple associated grants. We've introduced a more holistic fix in 7.16.1 that produces unique and tenant-agnostic filenames for client grants. I'd really appreciate it if you gave it a shot!

@willvedd
Copy link
Contributor

willvedd commented Feb 8, 2023

Going to close this one out. If anyone has any additional feedback please feel empowered to create a new Github issue!

@willvedd willvedd closed this as completed Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants