discourse/lib/discourse_webauthn/challenge_generator.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
485 B
Ruby
Raw Permalink Normal View History

# 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