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

Token scopes no longer stored the same. #1697

Closed
joelharkes opened this issue Nov 5, 2023 · 5 comments
Closed

Token scopes no longer stored the same. #1697

joelharkes opened this issue Nov 5, 2023 · 5 comments

Comments

@joelharkes
Copy link

joelharkes commented Nov 5, 2023

Passport Version

11.9.2

Laravel Version

latest

PHP Version

8.2

Database Driver & Version

SQL Server

Description

we recently upgraded: v11.8.8...v11.9.2

We have some overwrites on the passport library but found a problem in the code:

Before we used to store the scope as: "scope1 scope2" space delimited string.
But now the code expects a Json_encoded field, otherwise it will always return true as the result for scope checking:

image image

Steps To Reproduce

Use old passport version 11.8.8 store a client scopes as space delimited string. but not it stores it as json_encoded array.

we had to do quite a migration to not break our codebase.

@driesvints
Copy link
Member

@axlon thoughts here? So far only one report though. The PR is already three months old almost so not sure if reverting is an option?

@driesvints
Copy link
Member

@joelharkes how are you storing scopes as a space delimiting string? Can you share some code?

@axlon
Copy link
Contributor

axlon commented Nov 6, 2023

@driesvints In my PR I assumed the changes would always be fully backwards compatible, because any previously existing scopes column would already have a cast in place to have the scopes come out of the model as an array, overwriting the casts provided by Passport's client.

It appears that @joelharkes is manually casting the scopes (encoding them before passing them to the model, and decoding them outside of the model). The easiest way to fix this would probably be to either make eloquent not use a cast for the scopes (by extending the client model and removing that specific cast) or creating a custom cast that deals with space delimited strings (which would require some code changes to classes that access the scopes on the client).

@driesvints
Copy link
Member

@axlon thanks! I'll await a code example from @joelharkes before continuing.

@driesvints
Copy link
Member

Closing this issue because it's inactive, already solved, old or not relevant anymore. Feel to open up a new issue if you're still experiencing this.

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

3 participants