Skip to content
Snippets Groups Projects
Commit 1ad34167 authored by James Edwards-Jones's avatar James Edwards-Jones
Browse files

TokenAuthenticatable provides comparison method

Avoids attempting save on comparison, as that could potentially reveal
that a resource exists.

Uses secure comparison incase this is reused somewhere sensitive.
parent 36979875
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -59,6 +59,11 @@ module TokenAuthenticatable
write_new_token(token_field, unique: unique)
save! if Gitlab::Database.read_write?
end
define_method("#{token_field}_matches?") do |other_token|
token = read_attribute(token_field)
token.present? && ActiveSupport::SecurityUtils.variable_size_secure_compare(other_token, token)
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment