Replies: 2 comments 8 replies
-
Hi @dhensby Can you provide us with a bit more context of your implementation? Which function are you invoking? I assume you are returning the token response directly to the user with an API call? |
Beta Was this translation helpful? Give feedback.
-
Yes, so this is for a very basic const server = new OAuth2Server({
model: new AuthModel(),
});
const token = await server.token(request, response);
// return the HTTP Response
return response; In v4 The const server = new OAuth2Server({
model: new AuthModel(),
});
const token = await server.token(request, response);
response.body = {
...response.body,
scope: token.scope.join(' '),
};
// return the HTTP Resonse
return response; This is pretty tightly coupled to my expectation that scope will always be present in the response (which it may not be in other applications) and also is just a bit nasty to have to re-write the response body in this way. If we could either set a config on the server or provide a scope-formatter, that would mean the internals can worry about whether there is even a scope prop to format. |
Beta Was this translation helpful? Give feedback.
-
I've been doing some work to upgrade a current implementation of v4 to v5 and noticed that the scope property is now treated as an array of strings.
Logically this makes sense within the internals of the OAuth server and the logic therein; often
scope
is actually a list of scopes that need to be validated against a token/client so treating these as a list makes a lot of sense.However, changing the response format of the Token response to also have
scope
as an array has a much wider reaching impact than a breaking change within the implementation details of the library, it impacts and forces a breaking change on every single consumer of the OAuth API being served by the library, making a graceful upgrade of clients "in the field" basically impossible.We have clients that are expecting
scope
to be a string, so changing it to a list is simply not feasible if we want to maintain access of deployed clients. This means we have to do some manual patching of responses to ensure the list of scopes is actually returned as a string instead of an array to ensure clients in the wild are not impacted.My personal preference would be that this change is reverted and scope is returned as a string in response bodies, but understand that may be difficult now that v5 is "stable"; alternatively could we provide either a scope formatter function for the request so we can easily format the scope property (allowing implementors to keep the legacy behaviour) or add a config option to opt-in to scope-as-string behaviour?
Beta Was this translation helpful? Give feedback.
All reactions