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

access_grant_class is broken. #174

Closed
Exterm1nate opened this issue Aug 1, 2022 · 7 comments
Closed

access_grant_class is broken. #174

Exterm1nate opened this issue Aug 1, 2022 · 7 comments
Labels

Comments

@Exterm1nate
Copy link

Steps to reproduce

# config/initializers/doorkeeper.rb
Doorkeeper.configure do
  access_grant_class "Oauth::AccessGrant"
end

# app/models/oauth/access_grant.rb
require "doorkeeper/orm/active_record/mixins/access_grant"

module Oauth
  class AccessGrant < ActiveRecord::Base
    include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant

  end
end

When starting application an error occures:

NameError: uninitialized constant Oauth
    Object.const_get(camel_cased_word)

I tried to require model in the initializer and the error changed:

Doorkeeper::MissingConfiguration: Configuration for doorkeeper missing. Do you have doorkeeper initializer?

With other two classes (access_token_class, application_class) application starts correctly.
Seems that lib/doorkeeper/openid_connect/orm/active_record.rb:35 is not working.

System configuration

Rails version: 7.0.3

Ruby version: 3.1.2

Doorkeeper version: 5.5.4

Doorkeeper OpenID version: 1.8.2

@nbulaj
Copy link
Member

nbulaj commented Aug 1, 2022

Thanks for reporting this!

Could be related to @nov changes here #168, I'll take a look closer a little bit later

@nbulaj nbulaj added the bug label Aug 1, 2022
nov added a commit to nov/doorkeeper-openid_connect-sample that referenced this issue Aug 1, 2022
@nov
Copy link
Contributor

nov commented Aug 1, 2022

I couldn't reproduced the error in this sample app.
https://github.com/nov/doorkeeper-openid_connect-sample

Are you missing app/models/oauth.rb which defines Oauth constant?

@Exterm1nate
Copy link
Author

I debuged my application and came to the conclusion that the problem is in the Sorcery gem.
Updated your sample app to demonstrate it.
https://github.com/Exterm1nate/doorkeeper-openid_connect-sample

@nov
Copy link
Contributor

nov commented Aug 1, 2022

Ah, because you have oauth gem, OAuth is already defined...

@Exterm1nate
Copy link
Author

It doesn't matter what class is provided.

The same issue for any other model, without Oauth namespace.

Doorkeeper.configure do
  access_grant_class "ApplicationRecord"
end

@nov
Copy link
Contributor

nov commented Aug 1, 2022

It seems because of Sorcery bug, which should be fixed in Sorcery v1.
Sorcery/sorcery#316
Sorcery/sorcery#312 (comment)

Does doorkeeper-openid_connect need some changes?

@Exterm1nate
Copy link
Author

Think we can close this.

@nbulaj nbulaj closed this as completed Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants