Add OAuth2 provider capability using doorkeeper gem (#24808).

Patch by Jens Krämer (user:jkraemer).

git-svn-id: https://svn.redmine.org/redmine/trunk@23837 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2025-06-12 07:09:03 +00:00
parent e56d84b632
commit 2d3b3b939e
29 changed files with 750 additions and 11 deletions

View File

@@ -131,6 +131,14 @@ class ApplicationController < ActionController::Base
if (key = api_key_from_request)
# Use API key
user = User.find_by_api_key(key)
elsif access_token = Doorkeeper.authenticate(request)
# Oauth
if access_token.accessible?
user = User.active.find_by_id(access_token.resource_owner_id)
user.oauth_scope = access_token.scopes.all.map(&:to_sym)
else
doorkeeper_render_error
end
elsif /\ABasic /i.match?(request.authorization.to_s)
# HTTP Basic, either username/password or API key/random
authenticate_with_http_basic do |username, password|