Code Monkey home page Code Monkey logo

Comments (9)

sgoranov avatar sgoranov commented on June 4, 2024 1

I also wonder why the User entity is not passed instead the identifier . This one is used only here:

vendor/league/oauth2-server/src/Grant/AbstractGrant.php

    protected function issueAuthCode(
        DateInterval $authCodeTTL,
        ClientEntityInterface $client,
        $userIdentifier,
        $redirectUri,
        array $scopes = []
    ) {
        $maxGenerationAttempts = self::MAX_RANDOM_TOKEN_GENERATION_ATTEMPTS;

        $authCode = $this->authCodeRepository->getNewAuthCode();
        $authCode->setExpiryDateTime((new DateTimeImmutable())->add($authCodeTTL));
        $authCode->setClient($client);
        $authCode->setUserIdentifier($userIdentifier);

vendor/league/oauth2-server/src/Grant/AuthCodeGrant.php

        if ($authorizationRequest->isAuthorizationApproved() === true) {
            $authCode = $this->issueAuthCode(
                $this->authCodeTTL,
                $authorizationRequest->getClient(),
                $authorizationRequest->getUser()->getIdentifier(),
                $authorizationRequest->getRedirectUri(),
                $authorizationRequest->getScopes()

And it looks like there is no problem to pass the whole User entity.
On the other hand the current behavior, i.e. using the identifier allows loading the users from somewhere else which I guess is the main idea behind this.

from oauth2-server.

Sephster avatar Sephster commented on June 4, 2024

Have you looked at the bundle for Symfony? It might be easier to integrate with your application using it

from oauth2-server.

DarthLegiON avatar DarthLegiON commented on June 4, 2024

@Sephster Unfortunately, we cannot use it as we have old Symfony version and not updated yet. But it's a good idea to look there for a workaround, thanks.

from oauth2-server.

DarthLegiON avatar DarthLegiON commented on June 4, 2024

@Sephster I see that the Symfony bundle doesn't make any foreign keys in the persistense entities and just fills DB with schema initialization code. It doesn't suit our requirements, we should make database manipulations with migrations.

I just can't understand why in this particular field you don't operate interface and use id. It doesn't make any sense for me.

from oauth2-server.

Sephster avatar Sephster commented on June 4, 2024

I can't speak as to why the code is like that as I didn't write the lines you are referencing. I am not sure why this would have such a bearing on your application code though. Are you able to share example code?

I believe people have successfully implemented this lib using Doctrine as the backend in the past as this issue hasn't been raised before so I'm hoping the fix can be done in userland rather than this codebase if possible

from oauth2-server.

DarthLegiON avatar DarthLegiON commented on June 4, 2024

Of course, I already found a workaround, but it looks a bit ugly.

from oauth2-server.

DarthLegiON avatar DarthLegiON commented on June 4, 2024

@sgoranov yes, I'm talking about the same: always when we're going to link accessToken/authCode to a user, we can pass User entity either and loose nothing. But looks like the code base already cannot be adapted for this, and it will break backward compatibility.

I only wanted to know what decision brought developers to this and understand the solution.

from oauth2-server.

Sephster avatar Sephster commented on June 4, 2024

The original developer of this is no longer involved in the project so I can't speak as to why it was implemented that way. Do you have a link to the Doctrine behaviour stating you must pass an object to create a relation? Thanks

from oauth2-server.

Sephster avatar Sephster commented on June 4, 2024

Closing due to lack of response

from oauth2-server.

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.