passkeys-rails 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +17 -2
- data/app/controllers/passkeys/rails/application_controller.rb +24 -0
- data/app/controllers/passkeys/rails/passkeys_controller.rb +63 -0
- data/app/models/concerns/passkeys/rails/authenticatable.rb +19 -0
- data/app/models/passkeys/rails/agent.rb +17 -0
- data/app/models/passkeys/rails/application_record.rb +7 -0
- data/app/models/passkeys/rails/error.rb +16 -0
- data/app/models/passkeys/rails/passkey.rb +10 -0
- data/config/routes.rb +1 -1
- data/lib/generators/passkeys_rails/USAGE +1 -1
- data/lib/generators/passkeys_rails/install_generator.rb +14 -12
- data/lib/generators/passkeys_rails/templates/README +2 -2
- data/lib/generators/passkeys_rails/templates/passkeys_rails_config.rb +2 -2
- data/lib/passkeys/rails/controllers/helpers.rb +33 -0
- data/lib/passkeys/rails/engine.rb +44 -0
- data/lib/passkeys/rails/interactors/begin_authentication.rb +11 -0
- data/lib/passkeys/rails/interactors/begin_challenge.rb +37 -0
- data/lib/passkeys/rails/interactors/begin_registration.rb +25 -0
- data/lib/passkeys/rails/interactors/finish_authentication.rb +55 -0
- data/lib/passkeys/rails/interactors/finish_registration.rb +79 -0
- data/lib/passkeys/rails/interactors/generate_auth_token.rb +29 -0
- data/lib/passkeys/rails/interactors/refresh_token.rb +19 -0
- data/lib/passkeys/rails/interactors/validate_auth_token.rb +35 -0
- data/lib/passkeys/rails/railtie.rb +19 -0
- data/lib/passkeys/rails/version.rb +5 -0
- data/lib/passkeys-rails.rb +36 -0
- metadata +26 -27
- data/app/controllers/passkeys_rails/application_controller.rb +0 -22
- data/app/controllers/passkeys_rails/passkeys_controller.rb +0 -61
- data/app/helpers/passkeys_rails/application_helper.rb +0 -21
- data/app/helpers/passkeys_rails/passkeys_helper.rb +0 -4
- data/app/interactors/passkeys_rails/begin_authentication.rb +0 -9
- data/app/interactors/passkeys_rails/begin_challenge.rb +0 -35
- data/app/interactors/passkeys_rails/begin_registration.rb +0 -23
- data/app/interactors/passkeys_rails/finish_authentication.rb +0 -53
- data/app/interactors/passkeys_rails/finish_registration.rb +0 -77
- data/app/interactors/passkeys_rails/generate_auth_token.rb +0 -27
- data/app/interactors/passkeys_rails/refresh_token.rb +0 -17
- data/app/interactors/passkeys_rails/validate_auth_token.rb +0 -33
- data/app/models/concerns/passkeys_rails/authenticatable.rb +0 -17
- data/app/models/passkeys_rails/agent.rb +0 -15
- data/app/models/passkeys_rails/application_record.rb +0 -5
- data/app/models/passkeys_rails/error.rb +0 -14
- data/app/models/passkeys_rails/passkey.rb +0 -8
- data/lib/passkeys_rails/engine.rb +0 -24
- data/lib/passkeys_rails/error_middleware.rb +0 -17
- data/lib/passkeys_rails/railtie.rb +0 -17
- data/lib/passkeys_rails/version.rb +0 -3
- data/lib/passkeys_rails.rb +0 -38
- /data/app/views/layouts/{passkeys_rails → passkeys/rails}/application.html.erb +0 -0
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'error_middleware'
|
2
|
-
module PasskeysRails
|
3
|
-
class Engine < ::Rails::Engine
|
4
|
-
isolate_namespace PasskeysRails
|
5
|
-
|
6
|
-
config.generators do |g|
|
7
|
-
g.test_framework :rspec
|
8
|
-
g.fixture_replacement :factory_bot
|
9
|
-
g.factory_bot dir: 'spec/factories'
|
10
|
-
g.assets false
|
11
|
-
g.helper false
|
12
|
-
end
|
13
|
-
|
14
|
-
config.to_prepare do
|
15
|
-
# include our helper methods in the host application's ApplicationController
|
16
|
-
::ApplicationController.include ApplicationHelper
|
17
|
-
end
|
18
|
-
|
19
|
-
# provide a way to bail out of the render flow if needed
|
20
|
-
initializer 'passkeys_rails.configure.middleware' do |app|
|
21
|
-
app.middleware.use ErrorMiddleware
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -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
|
data/lib/passkeys_rails.rb
DELETED
@@ -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
|
File without changes
|