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

auth.middleware.{js,ts} scopes format does not conform to what SDK authmiddleware options require #84

Open
sfernengel opened this issue Aug 7, 2024 · 0 comments

Comments

@sfernengel
Copy link

In the auth.middleware.{js,ts} files in each of the connect applications, we have the following code

  scopes: [
    readConfiguration().scope
      ? (readConfiguration().scope as string)
      : 'default',
  ],

This code only works if the CTP_SCOPE env variable contains a single value such as manage_project:xyz

To make it work with values separated by spaces, CTP_SCOPE=manage_customers:xyz manage_orders:xyz we need to modify the code to split a long string into an array of strings.

Suggestion: modify the code as follows:

scopes: readConfiguration().scope
    ? (readConfiguration().scope as string).split(' ')
    : undefined,

The undefined is there to tell the system that, the middleware will use the scopes assigned to the API Client while it was being created via MC or API.

In the future, there could be a pre-defined scope but since this is a template, I think undefined is a good fit.

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

No branches or pull requests

1 participant