active_authentication 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +120 -0
- data/Rakefile +8 -0
- data/app/controllers/active_authentication/confirmations_controller.rb +29 -0
- data/app/controllers/active_authentication/passwords_controller.rb +37 -0
- data/app/controllers/active_authentication/registrations_controller.rb +42 -0
- data/app/controllers/active_authentication/sessions_controller.rb +36 -0
- data/app/controllers/active_authentication/unlocks_controller.rb +29 -0
- data/app/mailers/active_authentication/mailer.rb +21 -0
- data/app/views/active_authentication/confirmations/new.html.erb +14 -0
- data/app/views/active_authentication/mailer/email_confirmation_instructions.html.erb +5 -0
- data/app/views/active_authentication/mailer/password_reset_instructions.html.erb +5 -0
- data/app/views/active_authentication/mailer/unlock_instructions.html.erb +5 -0
- data/app/views/active_authentication/passwords/edit.html.erb +28 -0
- data/app/views/active_authentication/passwords/new.html.erb +14 -0
- data/app/views/active_authentication/registrations/edit.html.erb +42 -0
- data/app/views/active_authentication/registrations/new.html.erb +35 -0
- data/app/views/active_authentication/sessions/new.html.erb +19 -0
- data/app/views/active_authentication/shared/_links.html.erb +19 -0
- data/app/views/active_authentication/unlocks/new.html.erb +14 -0
- data/config/i18n-tasks.yml +159 -0
- data/config/locales/en.yml +90 -0
- data/config/locales/es.yml +90 -0
- data/lib/active_authentication/controller/lockable.rb +31 -0
- data/lib/active_authentication/controller/trackable.rb +17 -0
- data/lib/active_authentication/controller.rb +48 -0
- data/lib/active_authentication/current.rb +5 -0
- data/lib/active_authentication/engine.rb +16 -0
- data/lib/active_authentication/model/authenticatable.rb +16 -0
- data/lib/active_authentication/model/confirmable.rb +54 -0
- data/lib/active_authentication/model/lockable.rb +42 -0
- data/lib/active_authentication/model/recoverable.rb +16 -0
- data/lib/active_authentication/model/registerable.rb +7 -0
- data/lib/active_authentication/model/trackable.rb +23 -0
- data/lib/active_authentication/model.rb +21 -0
- data/lib/active_authentication/routes.rb +34 -0
- data/lib/active_authentication/test/helpers.rb +13 -0
- data/lib/active_authentication/version.rb +3 -0
- data/lib/active_authentication.rb +42 -0
- data/lib/generators/active_authentication/install/install_generator.rb +53 -0
- data/lib/generators/active_authentication/install/templates/initializer.rb +14 -0
- data/lib/generators/active_authentication/install/templates/migration.rb +26 -0
- data/lib/generators/active_authentication/views/views_generator.rb +17 -0
- metadata +116 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require "active_authentication/version"
|
2
|
+
require "active_authentication/engine"
|
3
|
+
require "active_authentication/routes"
|
4
|
+
|
5
|
+
module ActiveAuthentication
|
6
|
+
include ActiveSupport::Configurable
|
7
|
+
|
8
|
+
autoload :Controller, "active_authentication/controller"
|
9
|
+
autoload :Current, "active_authentication/current"
|
10
|
+
autoload :Model, "active_authentication/model"
|
11
|
+
|
12
|
+
module Controller
|
13
|
+
autoload :Lockable, "active_authentication/controller/lockable"
|
14
|
+
autoload :Trackable, "active_authentication/controller/trackable"
|
15
|
+
end
|
16
|
+
|
17
|
+
module Model
|
18
|
+
autoload :Authenticatable, "active_authentication/model/authenticatable"
|
19
|
+
autoload :Confirmable, "active_authentication/model/confirmable"
|
20
|
+
autoload :Lockable, "active_authentication/model/lockable"
|
21
|
+
autoload :Recoverable, "active_authentication/model/recoverable"
|
22
|
+
autoload :Registerable, "active_authentication/model/registerable"
|
23
|
+
autoload :Trackable, "active_authentication/model/trackable"
|
24
|
+
end
|
25
|
+
|
26
|
+
module Test
|
27
|
+
autoload :Helpers, "active_authentication/test/helpers"
|
28
|
+
end
|
29
|
+
|
30
|
+
# authenticatable
|
31
|
+
config_accessor :min_password_length, default: 6
|
32
|
+
|
33
|
+
# confirmable
|
34
|
+
config_accessor :email_confirmation_token_expires_in, default: 24.hours
|
35
|
+
|
36
|
+
# lockable
|
37
|
+
config_accessor :unlock_token_expires_in, default: 24.hours
|
38
|
+
config_accessor :max_failed_attempts, default: 10
|
39
|
+
|
40
|
+
# recoverable
|
41
|
+
config_accessor :password_reset_token_expires_in, default: 1.hour
|
42
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class ActiveAuthentication::InstallGenerator < Rails::Generators::Base
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
|
4
|
+
source_root File.expand_path("templates", __dir__)
|
5
|
+
|
6
|
+
desc "Creates the User model, the active_authentication initializer, and adds the active_authentication route."
|
7
|
+
|
8
|
+
def self.next_migration_number(dirname)
|
9
|
+
ActiveRecord::Migration.new.next_migration_number 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate_model
|
13
|
+
invoke "active_record:model", %w[User], migration: false, skip_collision_check: true
|
14
|
+
|
15
|
+
if behavior == :invoke
|
16
|
+
inject_into_class "app/models/user.rb", "User", " authenticates_with :confirmable, :lockable, :recoverable, :registerable, :trackable\n"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_migration
|
21
|
+
migration_template "migration.rb", "db/migrate/create_users.rb", migration_version: migration_version, ip_column: ip_column
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_route
|
25
|
+
route "active_authentication"
|
26
|
+
end
|
27
|
+
|
28
|
+
def copy_initializer
|
29
|
+
template "initializer.rb", "config/initializers/active_authentication.rb"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def ar_config
|
35
|
+
if ActiveRecord::Base.configurations.respond_to?(:configs_for)
|
36
|
+
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").configuration_hash
|
37
|
+
else
|
38
|
+
ActiveRecord::Base.configurations[Rails.env]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def ip_column
|
43
|
+
postgresql? ? "inet" : "string"
|
44
|
+
end
|
45
|
+
|
46
|
+
def migration_version
|
47
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
48
|
+
end
|
49
|
+
|
50
|
+
def postgresql?
|
51
|
+
ar_config.present? && ar_config["adapter"] == "postgresql"
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
ActiveAuthentication.configure do |config|
|
2
|
+
# configuration for the authenticatable concern
|
3
|
+
# config.min_password_length = 6
|
4
|
+
|
5
|
+
# configuration for the confirmable concern
|
6
|
+
# config.email_confirmation_token_expires_in = 24.hours
|
7
|
+
|
8
|
+
# configuration for the lockable concern
|
9
|
+
# config.unlock_token_expires_in = 24.hours
|
10
|
+
# config.max_failed_attempts = 10
|
11
|
+
|
12
|
+
# configuration for the recoverable concern
|
13
|
+
# config.password_reset_token_expires_in = 1.hour
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
create_table :users do |t|
|
4
|
+
# authenticatable
|
5
|
+
t.string :email, null: false
|
6
|
+
t.string :password_digest, null: false
|
7
|
+
|
8
|
+
# confirmable
|
9
|
+
t.string :unconfirmed_email
|
10
|
+
|
11
|
+
# lockable
|
12
|
+
t.integer :failed_attempts, null: false, default: 0
|
13
|
+
t.datetime :locked_at
|
14
|
+
|
15
|
+
# trackable
|
16
|
+
t.integer :sign_in_count, null: false, default: 0
|
17
|
+
t.datetime :current_sign_in_at
|
18
|
+
t.datetime :last_sign_in_at
|
19
|
+
t.<%= ip_column %> :current_sign_in_ip
|
20
|
+
t.<%= ip_column %> :last_sign_in_ip
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
add_index :users, :email, unique: true
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ActiveAuthentication::ViewsGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path("../../../../", __dir__)
|
3
|
+
|
4
|
+
desc "Generates active_authentication's views."
|
5
|
+
|
6
|
+
class_option :views, aliases: "-v", type: :array, desc: "Views to generate (available: confirmations, mailer, passwords, registrations, sessions, shared, unlocks)"
|
7
|
+
|
8
|
+
def copy_views
|
9
|
+
if options[:views]
|
10
|
+
options[:views].each do |view|
|
11
|
+
directory "app/views/active_authentication/#{view}"
|
12
|
+
end
|
13
|
+
else
|
14
|
+
directory "app/views/active_authentication"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_authentication
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patricio Mac Adden
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bcrypt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.1'
|
41
|
+
description: A pure Rails authentication solution. Inspired by devise, but with a
|
42
|
+
pure Rails implementation.
|
43
|
+
email:
|
44
|
+
- patriciomacadden@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/controllers/active_authentication/confirmations_controller.rb
|
52
|
+
- app/controllers/active_authentication/passwords_controller.rb
|
53
|
+
- app/controllers/active_authentication/registrations_controller.rb
|
54
|
+
- app/controllers/active_authentication/sessions_controller.rb
|
55
|
+
- app/controllers/active_authentication/unlocks_controller.rb
|
56
|
+
- app/mailers/active_authentication/mailer.rb
|
57
|
+
- app/views/active_authentication/confirmations/new.html.erb
|
58
|
+
- app/views/active_authentication/mailer/email_confirmation_instructions.html.erb
|
59
|
+
- app/views/active_authentication/mailer/password_reset_instructions.html.erb
|
60
|
+
- app/views/active_authentication/mailer/unlock_instructions.html.erb
|
61
|
+
- app/views/active_authentication/passwords/edit.html.erb
|
62
|
+
- app/views/active_authentication/passwords/new.html.erb
|
63
|
+
- app/views/active_authentication/registrations/edit.html.erb
|
64
|
+
- app/views/active_authentication/registrations/new.html.erb
|
65
|
+
- app/views/active_authentication/sessions/new.html.erb
|
66
|
+
- app/views/active_authentication/shared/_links.html.erb
|
67
|
+
- app/views/active_authentication/unlocks/new.html.erb
|
68
|
+
- config/i18n-tasks.yml
|
69
|
+
- config/locales/en.yml
|
70
|
+
- config/locales/es.yml
|
71
|
+
- lib/active_authentication.rb
|
72
|
+
- lib/active_authentication/controller.rb
|
73
|
+
- lib/active_authentication/controller/lockable.rb
|
74
|
+
- lib/active_authentication/controller/trackable.rb
|
75
|
+
- lib/active_authentication/current.rb
|
76
|
+
- lib/active_authentication/engine.rb
|
77
|
+
- lib/active_authentication/model.rb
|
78
|
+
- lib/active_authentication/model/authenticatable.rb
|
79
|
+
- lib/active_authentication/model/confirmable.rb
|
80
|
+
- lib/active_authentication/model/lockable.rb
|
81
|
+
- lib/active_authentication/model/recoverable.rb
|
82
|
+
- lib/active_authentication/model/registerable.rb
|
83
|
+
- lib/active_authentication/model/trackable.rb
|
84
|
+
- lib/active_authentication/routes.rb
|
85
|
+
- lib/active_authentication/test/helpers.rb
|
86
|
+
- lib/active_authentication/version.rb
|
87
|
+
- lib/generators/active_authentication/install/install_generator.rb
|
88
|
+
- lib/generators/active_authentication/install/templates/initializer.rb
|
89
|
+
- lib/generators/active_authentication/install/templates/migration.rb
|
90
|
+
- lib/generators/active_authentication/views/views_generator.rb
|
91
|
+
homepage: https://github.com/sinaptia/active_authentication
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata:
|
95
|
+
homepage_uri: https://github.com/sinaptia/active_authentication
|
96
|
+
source_code_uri: https://github.com/sinaptia/active_authentication
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubygems_version: 3.0.3.1
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: A pure Rails authentication solution
|
116
|
+
test_files: []
|