Code Monkey home page Code Monkey logo

Comments (7)

driesvints avatar driesvints commented on August 21, 2024

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

from sanctum.

nicoqh avatar nicoqh commented on August 21, 2024

@driesvints

Not sure how this can be mistaken for a support question.

from sanctum.

driesvints avatar driesvints commented on August 21, 2024

Hi @nicoqh. You seem to be asking questions about how things work in Sanctum. That's a support question. This issue tracker is only for reporting bugs. There's also no bug template filled in here.

from sanctum.

nicoqh avatar nicoqh commented on August 21, 2024

Hi, @driesvints

No, I questioned the guard's implementation. And I assumed it was a good idea to ask a question about the design decisions before possibly submitting a PR. I'd open a discussion, but there's no such feature enabled on the repo.

from sanctum.

Ilyes512 avatar Ilyes512 commented on August 21, 2024

@driesvints I totally agree with @nicoqh. This does belong here as its not so much a support question, but a technical question in regards to the code it self. We know what the issue is and we know how to fix it, but we need some input from the maintainers before doing anything like suggesting a change through a PR. I believe the need to take issues to zero is taking precedence over actually carefully reading the issue.

But in any case this is why I landed here:

I came here after I was reading Sanctum's code, because I have a specific case where the users would be on 1 connection (server a) and the tokens on another (server b) and I was unpleasantly surprised to see this unnecessary tight coupling preventing me from otherwise easily implementing this.

Sanctum also provides a Laravel\Sanctum\Contracts\HasApiTokens-interface, but that is surprisingly only used in DocBlock annotations!?

Using the "trait" check is probably done to prevent users from also having to add an implements HasApiToken interface besides adding the trait.

Ideally the supportsTokens should check wether it supports tokens by checking if $tokenable implements the interface and not the very specific trait. This might be a to large of a change to do without a version bump perhaps?

Another solution might be to make it possible to "overwrite" the supportsTokens logic by perhaps giving us the option to set a callable that would be used instead if set. I have seen this pattern used more within the Laravel code base (don't have an example on hand, but I know they are there).

edit:

So all it takes is this small change: 4.x...Ilyes512:sanctum:update-supports-token-logic-by-checking-contract

Funny thing is, I was expecting one or more tests to fail, but it didn't because the model that is used with the tests already explicitly implements the HasApiTokens-interface. See https://github.com/laravel/sanctum/blob/4.x/workbench/app/Models/User.php#L9

from sanctum.

driesvints avatar driesvints commented on August 21, 2024

I believe the need to take issues to zero is taking precedence over actually carefully reading the issue.

I wouldn't be too quick to judge. It's easy to judge another if you're not in their shoes. We definitely welcome PR's if there's something to be improved here which is what you've done. So let's see how it goes.

from sanctum.

Ilyes512 avatar Ilyes512 commented on August 21, 2024

I wouldn't be too quick to judge. It's easy to judge another if you're not in their shoes.

True, I can only imagine you and the rest of the Laravel team are quite busy maintaining existing code and delivering awesome new stuff. And I am thank full of that!

It's just sometimes it feels like tickets get closed to quick, but I also understand you need to prioritise stuff.


Also I actually don't need the change anymore... but I still think it's better to check against the interface if you want to enable people changing the specific implementation detail.

from sanctum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.