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

Doorkeeper::Application#as_json can have "id" as BSON::ObjectId instead of String for app owner #68

Open
hiroshi opened this issue Jul 1, 2021 · 2 comments

Comments

@hiroshi
Copy link

hiroshi commented Jul 1, 2021

Steps to reproduce

86b593e2d1fe495c970e516e93722748

I'll provide more details if you don't get it. Or create a pull request when I can.

Expected behavior

app.as_json(current_resource_owner: app.owner)['id'].is_a?(String) == true

Actual behavior

app.as_json(current_resource_owner: app.owner)['id'].is_a?(String) != true
app.as_json(current_resource_owner: app.owner)['id'].is_a?(BSON::ObjectId) == true

System configuration

Ruby version:
2.7.3

Gemfile.lock
doorkeeper (5.5.2)
doorkeeper-mongodb (5.2.2)
mongo (2.14.0)
mongoid (6.4.8)
rails (5.2.6)

@hiroshi
Copy link
Author

hiroshi commented Jul 1, 2021

I think #53 causes this issue.

As a workaround I did this for a rails project. I don't care that owner only see restricted attributes since it makes more consisted result for GET /oauth/authorized_applications.json.

# config/initializers/doorkeeper.rb 
Doorkeeper::Application.class_eval do
  def as_json(options = {})
    only = extract_serializable_attributes(options)
    super(options.merge(only: only))
  end
end

@johnnyshields
Copy link

johnnyshields commented Jun 25, 2022

@hiroshi please check if this is still happening on the latest Doorkeeper + Doorkeeper-MongoDB + Mongoid + BSON gem versions?

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

No branches or pull requests

2 participants