Skip to content

Commit

Permalink
Fix doorkeeper scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed Jan 21, 2024
1 parent 8b7300a commit 2b0ede3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def authenticated
end

def admin_authenticated
!!doorkeeper_token.id && doorkeeper_token.scopes.include?('admin')
!!doorkeeper_token.id && doorkeeper_token.scopes&.include?('admin')
end

def current_user
Expand Down
6 changes: 0 additions & 6 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ def item(full_identifier:)
argument :full_identifier, ID
end
def item_bwf_xml(full_identifier:)
p 'MOO'
p 'MOO'
p 'MOO'
p 'MOO'
p 'MOO'
p context
raise(GraphQL::ExecutionError, 'Not authorised') unless context[:admin_authenticated]

collection_identifier, item_identifier = full_identifier.split('-')
Expand Down
2 changes: 1 addition & 1 deletion app/views/items/show_bwf.xml.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%Core
%Description
= "# Notes
= "# Notes"
= "Reference: https://catalog.paradisec.org.au/repository/#{@item.collection.identifier}/#{@item.identifier}"
= ""
= "Description: #{@item.description}."
Expand Down
6 changes: 3 additions & 3 deletions config/initializers/doorkeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
# For more information go to
# https://doorkeeper.gitbook.io/guides/ruby-on-rails/scopes
#
# default_scopes :public
# optional_scopes :write, :update
default_scopes :read
optional_scopes :write, :admin

# Allows to restrict only certain scopes for grant_type.
# By default, all the scopes will be available for all the grant types.
Expand All @@ -246,7 +246,7 @@
# not in configuration, i.e. +default_scopes+ or +optional_scopes+.
# (disabled by default)
#
# enforce_configured_scopes
enforce_configured_scopes

# Change the way client credentials are retrieved from the request object.
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
Expand Down

0 comments on commit 2b0ede3

Please sign in to comment.