passkeys-rails 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +4 -4
  4. data/app/controllers/concerns/passkeys_rails/authentication.rb +29 -0
  5. data/app/controllers/passkeys_rails/application_controller.rb +22 -0
  6. data/app/controllers/passkeys_rails/passkeys_controller.rb +61 -0
  7. data/app/interactors/passkeys_rails/begin_authentication.rb +9 -0
  8. data/app/interactors/passkeys_rails/begin_challenge.rb +35 -0
  9. data/app/interactors/passkeys_rails/begin_registration.rb +23 -0
  10. data/app/interactors/passkeys_rails/finish_authentication.rb +53 -0
  11. data/app/interactors/passkeys_rails/finish_registration.rb +77 -0
  12. data/app/interactors/passkeys_rails/generate_auth_token.rb +27 -0
  13. data/app/interactors/passkeys_rails/refresh_token.rb +17 -0
  14. data/app/interactors/passkeys_rails/validate_auth_token.rb +33 -0
  15. data/app/models/concerns/passkeys_rails/authenticatable.rb +17 -0
  16. data/app/models/passkeys_rails/agent.rb +15 -0
  17. data/app/models/passkeys_rails/application_record.rb +5 -0
  18. data/app/models/passkeys_rails/error.rb +14 -0
  19. data/app/models/passkeys_rails/passkey.rb +8 -0
  20. data/config/initializers/application_controller.rb +12 -0
  21. data/config/routes.rb +1 -1
  22. data/lib/generators/passkeys_rails/USAGE +1 -1
  23. data/lib/generators/passkeys_rails/install_generator.rb +12 -14
  24. data/lib/generators/passkeys_rails/templates/README +1 -1
  25. data/lib/generators/passkeys_rails/templates/passkeys_rails_config.rb +1 -1
  26. data/lib/passkeys-rails.rb +21 -23
  27. data/lib/passkeys_rails/engine.rb +21 -0
  28. data/lib/passkeys_rails/railtie.rb +17 -0
  29. data/lib/passkeys_rails/version.rb +3 -0
  30. metadata +22 -24
  31. data/app/assets/config/passkeys_rails_manifest.js +0 -1
  32. data/app/assets/stylesheets/passkeys_rails/application.css +0 -15
  33. data/app/controllers/passkeys/rails/application_controller.rb +0 -24
  34. data/app/controllers/passkeys/rails/passkeys_controller.rb +0 -63
  35. data/app/models/concerns/passkeys/rails/authenticatable.rb +0 -19
  36. data/app/models/passkeys/rails/agent.rb +0 -17
  37. data/app/models/passkeys/rails/application_record.rb +0 -7
  38. data/app/models/passkeys/rails/error.rb +0 -16
  39. data/app/models/passkeys/rails/passkey.rb +0 -10
  40. data/app/views/layouts/passkeys/rails/application.html.erb +0 -15
  41. data/lib/passkeys/rails/controllers/helpers.rb +0 -33
  42. data/lib/passkeys/rails/engine.rb +0 -44
  43. data/lib/passkeys/rails/interactors/begin_authentication.rb +0 -11
  44. data/lib/passkeys/rails/interactors/begin_challenge.rb +0 -37
  45. data/lib/passkeys/rails/interactors/begin_registration.rb +0 -25
  46. data/lib/passkeys/rails/interactors/finish_authentication.rb +0 -55
  47. data/lib/passkeys/rails/interactors/finish_registration.rb +0 -79
  48. data/lib/passkeys/rails/interactors/generate_auth_token.rb +0 -29
  49. data/lib/passkeys/rails/interactors/refresh_token.rb +0 -19
  50. data/lib/passkeys/rails/interactors/validate_auth_token.rb +0 -35
  51. data/lib/passkeys/rails/railtie.rb +0 -19
  52. data/lib/passkeys/rails/version.rb +0 -5
@@ -1,35 +0,0 @@
1
- module Passkeys
2
- module Rails
3
- class ValidateAuthToken
4
- include Interactor
5
-
6
- delegate :auth_token, to: :context
7
-
8
- def call
9
- context.fail!(code: :missing_token, message: "X-Auth header is required") if auth_token.blank?
10
-
11
- context.agent = fetch_agent
12
- end
13
-
14
- private
15
-
16
- def fetch_agent
17
- agent = Agent.find_by(id: payload['agent_id'])
18
- context.fail!(code: :invalid_token, message: "Invalid token - no agent exists with agent_id") if agent.blank?
19
-
20
- agent
21
- end
22
-
23
- def payload
24
- JWT.decode(auth_token,
25
- Passkeys::Rails.auth_token_secret,
26
- true,
27
- { required_claims: %w[exp agent_id], algorithm: Passkeys::Rails.auth_token_algorithm }).first
28
- rescue JWT::ExpiredSignature
29
- context.fail!(code: :expired_token, message: "The token has expired")
30
- rescue StandardError => e
31
- context.fail!(code: :token_error, message: e.message)
32
- end
33
- end
34
- end
35
- end
@@ -1,19 +0,0 @@
1
- require 'passkeys-rails'
2
- require 'rails'
3
-
4
- module Passkeys
5
- module Rails
6
- class Railtie < ::Rails::Railtie
7
- railtie_name :passkeys_rails
8
-
9
- rake_tasks do
10
- path = File.expand_path(__dir__)
11
- Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
12
- end
13
-
14
- generators do
15
- require "generators/passkeys_rails/install_generator"
16
- end
17
- end
18
- end
19
- end
@@ -1,5 +0,0 @@
1
- module Passkeys
2
- module Rails
3
- VERSION = "0.1.2".freeze
4
- end
5
- end