passkeys-rails 0.1.1 → 0.1.2

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 +15 -0
  3. data/README.md +17 -2
  4. data/app/controllers/passkeys/rails/application_controller.rb +24 -0
  5. data/app/controllers/passkeys/rails/passkeys_controller.rb +63 -0
  6. data/app/models/concerns/passkeys/rails/authenticatable.rb +19 -0
  7. data/app/models/passkeys/rails/agent.rb +17 -0
  8. data/app/models/passkeys/rails/application_record.rb +7 -0
  9. data/app/models/passkeys/rails/error.rb +16 -0
  10. data/app/models/passkeys/rails/passkey.rb +10 -0
  11. data/config/routes.rb +1 -1
  12. data/lib/generators/passkeys_rails/USAGE +1 -1
  13. data/lib/generators/passkeys_rails/install_generator.rb +14 -12
  14. data/lib/generators/passkeys_rails/templates/README +2 -2
  15. data/lib/generators/passkeys_rails/templates/passkeys_rails_config.rb +2 -2
  16. data/lib/passkeys/rails/controllers/helpers.rb +33 -0
  17. data/lib/passkeys/rails/engine.rb +44 -0
  18. data/lib/passkeys/rails/interactors/begin_authentication.rb +11 -0
  19. data/lib/passkeys/rails/interactors/begin_challenge.rb +37 -0
  20. data/lib/passkeys/rails/interactors/begin_registration.rb +25 -0
  21. data/lib/passkeys/rails/interactors/finish_authentication.rb +55 -0
  22. data/lib/passkeys/rails/interactors/finish_registration.rb +79 -0
  23. data/lib/passkeys/rails/interactors/generate_auth_token.rb +29 -0
  24. data/lib/passkeys/rails/interactors/refresh_token.rb +19 -0
  25. data/lib/passkeys/rails/interactors/validate_auth_token.rb +35 -0
  26. data/lib/passkeys/rails/railtie.rb +19 -0
  27. data/lib/passkeys/rails/version.rb +5 -0
  28. data/lib/passkeys-rails.rb +36 -0
  29. metadata +24 -25
  30. data/app/controllers/passkeys_rails/application_controller.rb +0 -22
  31. data/app/controllers/passkeys_rails/passkeys_controller.rb +0 -61
  32. data/app/helpers/passkeys_rails/application_helper.rb +0 -21
  33. data/app/helpers/passkeys_rails/passkeys_helper.rb +0 -4
  34. data/app/interactors/passkeys_rails/begin_authentication.rb +0 -9
  35. data/app/interactors/passkeys_rails/begin_challenge.rb +0 -35
  36. data/app/interactors/passkeys_rails/begin_registration.rb +0 -23
  37. data/app/interactors/passkeys_rails/finish_authentication.rb +0 -53
  38. data/app/interactors/passkeys_rails/finish_registration.rb +0 -77
  39. data/app/interactors/passkeys_rails/generate_auth_token.rb +0 -27
  40. data/app/interactors/passkeys_rails/refresh_token.rb +0 -17
  41. data/app/interactors/passkeys_rails/validate_auth_token.rb +0 -33
  42. data/app/models/concerns/passkeys_rails/authenticatable.rb +0 -17
  43. data/app/models/passkeys_rails/agent.rb +0 -15
  44. data/app/models/passkeys_rails/application_record.rb +0 -5
  45. data/app/models/passkeys_rails/error.rb +0 -14
  46. data/app/models/passkeys_rails/passkey.rb +0 -8
  47. data/lib/passkeys_rails/engine.rb +0 -24
  48. data/lib/passkeys_rails/error_middleware.rb +0 -17
  49. data/lib/passkeys_rails/railtie.rb +0 -17
  50. data/lib/passkeys_rails/version.rb +0 -3
  51. data/lib/passkeys_rails.rb +0 -38
  52. /data/app/views/layouts/{passkeys_rails → passkeys/rails}/application.html.erb +0 -0
@@ -1,17 +0,0 @@
1
- module PasskeysRails
2
- class ErrorMiddleware
3
- def initialize(app)
4
- @app = app
5
- end
6
-
7
- def call(env)
8
- begin
9
- response = @app.call(env)
10
- rescue Error => e
11
- return [401, { 'Content-Type' => 'application/json' }, e.to_h.to_json]
12
- end
13
-
14
- response
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'passkeys_rails'
2
- require 'rails'
3
-
4
- module PasskeysRails
5
- class Railtie < Rails::Railtie
6
- railtie_name :passkeys_rails
7
-
8
- rake_tasks do
9
- path = File.expand_path(__dir__)
10
- Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
11
- end
12
-
13
- generators do
14
- require "generators/passkeys_rails/install_generator"
15
- end
16
- end
17
- end
@@ -1,3 +0,0 @@
1
- module PasskeysRails
2
- VERSION = "0.1.1".freeze
3
- end
@@ -1,38 +0,0 @@
1
- require_relative "passkeys_rails/version"
2
- require_relative "passkeys_rails/engine"
3
- require_relative "generators/passkeys_rails/install_generator"
4
- require "rails"
5
- require "active_support/core_ext/numeric/time"
6
- require "active_support/dependencies"
7
- require "interactor"
8
- require "jwt"
9
- require "webauthn"
10
-
11
- module PasskeysRails
12
- # Secret used to encode the auth token.
13
- # Rails.application.secret_key_base is used if none is defined here.
14
- # Changing this value will invalidate all tokens that have been fetched
15
- # through the API.
16
- mattr_accessor(:auth_token_secret)
17
-
18
- # Algorithm used to generate the auth token.
19
- # Changing this value will invalidate all tokens that have been fetched
20
- # through the API.
21
- mattr_accessor :auth_token_algorithm, default: "HS256"
22
-
23
- # How long the auth token is valid before requiring a refresh or new login.
24
- # Set it to 0 for no expiration (not recommended in production).
25
- mattr_accessor :auth_token_expires_in, default: 30.days
26
-
27
- class << self
28
- def config
29
- yield self
30
- end
31
- end
32
-
33
- require 'passkeys_rails/railtie' if defined?(Rails)
34
- end
35
-
36
- ActiveSupport.on_load(:before_initialize) do
37
- PasskeysRails.auth_token_secret ||= Rails.application.secret_key_base
38
- end