bin/oauth2-server in rack-oauth2-server-1.3.1 vs bin/oauth2-server in rack-oauth2-server-1.4.0
- old
+ new
@@ -60,21 +60,21 @@
end
print <<-TEXT
Make sure you ONLY authorize administrators to use the oauth-admin scope.
For example:
- def authorize
+ before_filter do
# Only admins allowed to authorize the scope oauth-admin
- if oauth.scope.include?("oauth-admin") && !current_user.admin?
- oauth.deny! oauth.authorization
- end
+ head oauth.deny! if oauth.scope.include?("oauth-admin") && !current_user.admin?
end
Rails 2.x, add the following to config/environment.rb:
- config.middleware.use Rack::OAuth2::Server::Admin.mount "#{uri.path}"
- Rack::OAuth2::Server::Admin.set :client_id, "#{client.id}"
- Rack::OAuth2::Server::Admin.set :client_secret, "#{client.secret}"
+ config.after_initialize do
+ config.middleware.use Rack::OAuth2::Server::Admin.mount "#{uri.path}"
+ Rack::OAuth2::Server::Admin.set :client_id, "#{client.id}"
+ Rack::OAuth2::Server::Admin.set :client_secret, "#{client.secret}"
+ end
Sinatra, Padrino and other Rack applications, mount the console:
Rack::Builder.new do
map("#{uri.path}") { run Rack::OAuth2::Server::Admin }