Code Monkey home page Code Monkey logo

Comments (6)

bocharsky-bw avatar bocharsky-bw commented on August 25, 2024 2

Yay, glad it wasn't a bug on our side :)

Cheers!

from oauth2-client-bundle.

GriefCode avatar GriefCode commented on August 25, 2024 1

I can confirm that the autoloader setting is correct, according to the composer.json:

    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },

Maybe, I haven't dumped the composer file, but that should have been done automatically after using the composer install. I will check that later today when I am back home, as well as provide the info about the dump.

from oauth2-client-bundle.

GriefCode avatar GriefCode commented on August 25, 2024 1

Sorry for the late reply, was a bit busy.
It appears that it was not dumped. It is working now as expected. Thanks for your help 😃

from oauth2-client-bundle.

bocharsky-bw avatar bocharsky-bw commented on August 25, 2024

Thanks for this report!

I see it checks for provider class before throwing exception: if ($this->checkExternalClassExistence && !class_exists($providerClass)), so if your provider's class exists - you should not see this error. What is your provider class?

from oauth2-client-bundle.

GriefCode avatar GriefCode commented on August 25, 2024

I'm using a custom provider as I use a generic oauth2 server, this is my provider class:

<?php

namespace App\Security\Provider;

use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
use League\OAuth2\Client\Token\AccessToken;
use Psr\Http\Message\ResponseInterface;

class IPSProvider extends AbstractProvider {
    /**
     * Returns the base URL for authorizing a client.
     *
     * Eg. https://oauth.service.com/authorize
     *
     * @return string
     */
    public function getBaseAuthorizationUrl() {
        return "https:/whatever.com/oauth/authorize.php";
    }

    /**
     * Returns the base URL for requesting an access token.
     *
     * Eg. https://oauth.service.com/token
     *
     * @param array $params
     * @return string
     */
    public function getBaseAccessTokenUrl(array $params) {
        return "https://whatever.com/oauth/token.php";
    }

    /**
     * Returns the URL for requesting the resource owner's details.
     *
     * @param AccessToken $token
     * @return string
     */
    public function getResourceOwnerDetailsUrl(AccessToken $token) {
        return "https://whatever.com/oauth/me.php";
    }

    /**
     * Returns the default scopes used by this provider.
     *
     * This should only be the scopes that are required to request the details
     * of the resource owner, rather than all the available scopes.
     *
     * @return array
     */
    protected function getDefaultScopes() {
        return [];
    }

    /**
     * Checks a provider response for errors.
     *
     * @throws IdentityProviderException
     * @param  ResponseInterface $response
     * @param  array|string $data Parsed response data
     * @return void
     */
    protected function checkResponse(ResponseInterface $response, $data) {
    }

    /**
     * Generates a resource owner object from a successful resource owner
     * details request.
     *
     * @param  array $response
     * @param  AccessToken $token
     * @return ResourceOwnerInterface
     */
    protected function createResourceOwner(array $response, AccessToken $token) {
    }
}

And this is my config:

knpu_oauth2_client:
    clients:
        # will create service: "knpu.oauth2.client.foo_bar_oauth"
        # an instance of: KnpU\OAuth2ClientBundle\Client\OAuth2Client
        ips:
            type: generic
            provider_class: App\Security\Provider\IPSProvider

            # optional: a class that extends OAuth2Client
            # client_class: Some\Custom\Client

            # optional: if your provider has custom constructor options
            # provider_options: {}

            # now, all the normal options!
            client_id: <client_id>
            client_secret: <client_secret>
            redirect_route: oauth2_connect_ips_check
            redirect_params: {}

Could it be possible caused by using symfony 4.1?

from oauth2-client-bundle.

bocharsky-bw avatar bocharsky-bw commented on August 25, 2024

Thanks for providing this info! I don't think the problem with Symfony 4.1. As for me, it looks like Composer autoloader can't find this class. According to your config, your class should have exactly the next path: src/Security/Provider/IPSProvider.php and in composer.json you should have this App\ alias as:

{
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
}

Please, could you double check that this is true for you?

It would be great if you may debug actual provider class passed to configureProviderAndClient() method, you can temporarily add var_dump($providerClass); die; statements before this line: https://github.com/knpuniversity/oauth2-client-bundle/blob/master/src/DependencyInjection/KnpUOAuth2ClientExtension.php#L224

from oauth2-client-bundle.

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.