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

client yielded to allow_grant_flow_for_client config can either be a client or an application object #1398

Closed
aclemons opened this issue Apr 14, 2020 · 3 comments · Fixed by #1400

Comments

@aclemons
Copy link
Contributor

Steps to reproduce

When setting allow_grant_flow_for_client in the doorkeeper config, the client that is yielded can be of two different types.

Is this intentional? It means when configuring the lamba, we must deal with the differing types.

This is using the latest released version 5.3.1. (links above to the code in 5.3.1)

Thanks

@aclemons aclemons changed the title client yielded to allow_grant_flow_for_client config can either ba a client or an application object client yielded to allow_grant_flow_for_client config can either be a client or an application object Apr 14, 2020
@nbulaj
Copy link
Member

nbulaj commented Apr 14, 2020

Hi @aclemons . It's a bug, in all the cases client must be application instance. Would you like to prepare a PR?

@aclemons
Copy link
Contributor Author

Yes, I'll do this. Thanks.

@aclemons
Copy link
Contributor Author

I've open a pull request to address the client credentials case. This is the one I found leading me to open this issue. Looking at the password_access_token_request.rb case, I'm not sure if it is correct or not. The spec passes an application as "client" here. I think this is incorrect after looking at the prod code here.

module Doorkeeper
  module Request
    class Password < Strategy
      delegate :credentials, :resource_owner, :parameters, :client, to: :server

      def request
        @request ||= OAuth::PasswordAccessTokenRequest.new(
          Doorkeeper.config,
          client,
          resource_owner,
          parameters,
        )
      end
    end
  end
end

Client is what server.client returns, which is a client instance, not an application. Client delegates scopes to the application, so I guess that is why no one has noticed.

If we agree, I'll update the spec and change the code in password_access_token_request.rb to use client.application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants