mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-20 00:35:22 +00:00
protect against timing attacks for admin keys (#766)
This commit is contained in:
parent
097e48471f
commit
6b56134df4
1 changed files with 2 additions and 1 deletions
|
|
@ -9,7 +9,8 @@ module Api
|
|||
|
||||
def authenticate_admin_api_key!
|
||||
authenticate_or_request_with_http_token do |token, options|
|
||||
@admin_api_key = AdminApiKey.active.find_by(token: token)
|
||||
admin_api_key = AdminApiKey.active.find { |key| ActiveSupport::SecurityUtils.secure_compare(key.token, token) }
|
||||
@admin_api_key = admin_api_key
|
||||
|
||||
if @admin_api_key
|
||||
@current_user = @admin_api_key.user
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue