mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 15:13:41 +08:00
This is part 1 of 3, split up of PR #23529. This PR refactors the webauthn code to support passkey authentication/registration. Passkeys aren't used yet, that is coming in PRs 2 and 3. Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
22 lines
485 B
Ruby
22 lines
485 B
Ruby
# frozen_string_literal: true
|
|
module DiscourseWebauthn
|
|
class ChallengeGenerator
|
|
class ChallengeSession
|
|
attr_reader :challenge
|
|
|
|
def initialize(params)
|
|
@challenge = params[:challenge]
|
|
end
|
|
|
|
def commit_to_session(secure_session, user)
|
|
secure_session[DiscourseWebauthn.session_challenge_key(user)] = @challenge
|
|
|
|
self
|
|
end
|
|
end
|
|
|
|
def self.generate
|
|
ChallengeSession.new(challenge: SecureRandom.hex(30))
|
|
end
|
|
end
|
|
end
|