doorkeeper-mongodb
doorkeeper-mongodb copied to clipboard
Doorkeeper::Application#as_json can have "id" as BSON::ObjectId instead of String for app owner
Steps to reproduce
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)
I think https://github.com/doorkeeper-gem/doorkeeper-mongodb/pull/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
@hiroshi please check if this is still happening on the latest Doorkeeper + Doorkeeper-MongoDB + Mongoid + BSON gem versions?