trestle-auth-otp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fa70c1631d8f06c4e290a69ccef4bad9f5e02684d7af49d1cd0bc496ff499d23
4
+ data.tar.gz: ac440bb9299832f574996ba8dc782d301378d939182235b381a6cc40d5c43601
5
+ SHA512:
6
+ metadata.gz: 55d0941ed0ae31609d51744bb0f80224eb698bf4a2e12381c993b597fd33ddf26e7f866f9e9d1dbba441a97f127ab14ccefd2306c9b950143c7a1252cea805a9
7
+ data.tar.gz: ff0f42eb7c5abe45e36a66fe3cef72350341c17dd5c6f470a73d16f1a59da4e54b7dbe5fe1cc93bee7354119680602f730f94a02a2897ad2d96546a41c4a6dba
@@ -0,0 +1 @@
1
+ > 0.25%
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /node_modules/
11
+ /spec/dummy/db/*.sqlite3
12
+ /spec/dummy/*.sqlite3-journal
13
+ /spec/dummy/log/*.log
14
+ /spec/dummy/tmp/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
8
+
9
+ rvm:
10
+ - 2.6.5
11
+
12
+ gemfile:
13
+ - gemfiles/rails-5.0.gemfile
14
+ - gemfiles/rails-5.1.gemfile
15
+ - gemfiles/rails-5.2.gemfile
16
+ - gemfiles/rails-6.0.gemfile
17
+
18
+ jobs:
19
+ include:
20
+ gemfile: gemfiles/rails-4.2.gemfile
21
+ before_install:
22
+ - gem install bundler -v '< 2'
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trestle-auth.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem "coveralls", require: false
8
+
9
+ gem "capybara"
10
+ gem "sqlite3", "~> 1.4"
11
+ gem "devise"
12
+ end
13
+
14
+ gem "sassc-rails"
15
+
16
+ gem "rake", "~> 12.0"
17
+
18
+ gem "trestle", github: "TrestleAdmin/trestle"
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,37 @@
1
+ # Trestle Authentication One Time Password (trestle-auth-otp)
2
+
3
+ ## Getting Started
4
+
5
+ These instructions assume you have a working Trestle application. To integrate trestle-auth-otp, first add it to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'trestle-auth-otp'
9
+ ```
10
+
11
+ Run `bundle install`, and then run the install generator to set up configuration options, user model and user admin resource.
12
+
13
+ $ rails generate trestle:auth:install
14
+ $ rails generate trestle:auth:otp:install
15
+ $ rake db:migrate
16
+
17
+ Then create an initial admin user from the rails console:
18
+
19
+ $ rails console
20
+ > Administrator.create(email: "admin@example.com", password: "password", first_name: "Admin", last_name: "User")
21
+
22
+ To update existing records
23
+
24
+ $ rails console
25
+ > Administrator.find_each { |a| a.update_attribute(:otp_secret_key, Administrator.otp_random_secret) }
26
+
27
+ After restarting your Rails server, any attempt to access a page within your admin will redirect you to the login page.
28
+
29
+ OTP must be enabled in the Administrator form for every record.
30
+
31
+ ## Notes
32
+
33
+ This gem is based on the work done by Sam Pohlenz on trestle-auth
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [LGPLv3 License](https://opensource.org/licenses/LGPL-3.0).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,48 @@
1
+ class Trestle::Auth::SessionsController < Trestle::ApplicationController
2
+ layout 'trestle/auth'
3
+
4
+ skip_before_action :authenticate_user, only: [:new, :create]
5
+ skip_before_action :require_authenticated_user
6
+
7
+ def new; end
8
+
9
+ def create
10
+ if user = Trestle.config.auth.authenticate(params)
11
+
12
+ if user&.otp_module?
13
+ if params[:otp_code_token].size > 0
14
+ if user.authenticate_otp(params[:otp_code_token], drift: 60)
15
+ continue_sign_in(user)
16
+ else
17
+ logout!
18
+ flash[:error] = t('admin.auth.error', default: 'Bad Credentials Supplied.')
19
+ redirect_to instance_exec(&Trestle.config.auth.redirect_on_login)
20
+ end
21
+ else
22
+ logout!
23
+ flash[:error] = t('admin.auth.error', default: 'Your account needs to supply a token.')
24
+ redirect_to instance_exec(&Trestle.config.auth.redirect_on_login)
25
+ end
26
+ else
27
+ continue_sign_in(user)
28
+ end
29
+ else
30
+ flash[:error] = t('admin.auth.error', default: 'Incorrect login details.')
31
+ redirect_to action: :new
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ logout!
37
+ redirect_to instance_exec(&Trestle.config.auth.redirect_on_logout)
38
+ end
39
+
40
+ private
41
+
42
+ def continue_sign_in(user)
43
+ login!(user)
44
+ remember_me! if params[:remember_me] == '1'
45
+ redirect_to previous_location || instance_exec(&Trestle.config.auth.redirect_on_login)
46
+ end
47
+ end
48
+
@@ -0,0 +1,18 @@
1
+ <%- @qr = RQRCode::QRCode.new(@instance.provisioning_uri("#{Trestle.config.site_title} (#{@instance.email})"), size: 10, level: :h) %>
2
+
3
+ <div class="text-center">
4
+ <p><strong>Scan with Google Authenticator</strong></p>
5
+
6
+ <%= @qr.as_svg(
7
+ offset: 0,
8
+ color: '000',
9
+ shape_rendering: 'crispEdges',
10
+ module_size: 4,
11
+ standalone: true
12
+ ).html_safe %>
13
+
14
+ <small class="my-2">
15
+ <%= @instance.otp_secret_key %>
16
+ </small>
17
+
18
+ </div>
@@ -0,0 +1,8 @@
1
+ <div class="form-group">
2
+ <div class="input-group">
3
+ <div class="input-group-prepend">
4
+ <span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span>
5
+ </div>
6
+ <%= text_field_tag :otp_code_token, "", placeholder: 'Token', class: 'form-control' %>
7
+ </div>
8
+ </div>
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/trestle/auth/engine', __dir__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require "rails"
13
+ # Pick the frameworks you want:
14
+ require "active_model/railtie"
15
+ require "active_record/railtie"
16
+ require "action_controller/railtie"
17
+ require "action_view/railtie"
18
+ require "sprockets/railtie"
19
+ # require "rails/test_unit/railtie"
20
+ require 'rails/engine/commands'
@@ -0,0 +1,7 @@
1
+ Trestle.configure do |config|
2
+
3
+ config.hook('auth.login.form') do
4
+ render 'trestle/auth/otp'
5
+ end
6
+
7
+ end
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 4.2.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 5.0.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 5.1.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 5.2.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+
6
+ gem "capybara"
7
+ gem "sqlite3", "~> 1.4"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 6.0.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,30 @@
1
+ module Trestle
2
+ module Auth
3
+ module Otp
4
+ module Generators
5
+ class AdminGenerator < ::Rails::Generators::Base
6
+ desc "Creates a Trestle admin for managing Administrators"
7
+
8
+ argument :model, type: :string, default: "Administrator"
9
+
10
+ class_option :devise, type: :boolean, default: false, desc: "Create admin for a Devise user model"
11
+
12
+ source_root File.expand_path("../templates", __FILE__)
13
+
14
+ def create_admin
15
+ template "admin.rb.erb", File.join('app/admin/auth', "#{model.underscore.pluralize}_admin.rb")
16
+ end
17
+
18
+ def devise?
19
+ options[:devise]
20
+ end
21
+
22
+ protected
23
+ def plural_name
24
+ model.demodulize.underscore.pluralize
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,63 @@
1
+ Trestle.resource(:<%= plural_name %>, model: <%= model %>, scope: Auth) do
2
+ menu do
3
+ group :configuration, priority: :last do
4
+ item :<%= plural_name %>, icon: "fa fa-users"
5
+ end
6
+ end
7
+
8
+ table do
9
+ column :avatar, header: false do |administrator|
10
+ avatar_for(administrator)
11
+ end
12
+ column :email, link: true
13
+ column :otp_module, header: 'OTP'
14
+ <%- unless devise? -%>
15
+ column :first_name
16
+ column :last_name
17
+ <%- end -%>
18
+ actions do |a|
19
+ a.delete unless a.instance == current_user
20
+ end
21
+ end
22
+
23
+ form do |administrator|
24
+
25
+ sidebar do
26
+ render 'qr_code' if administrator.persisted?
27
+ end
28
+
29
+ text_field :email
30
+
31
+ <%- unless devise? -%>
32
+ row do
33
+ col(sm: 6) { text_field :first_name }
34
+ col(sm: 6) { text_field :last_name }
35
+ end
36
+
37
+ <%- end -%>
38
+ row do
39
+ col(sm: 6) { password_field :password }
40
+ col(sm: 6) { password_field :password_confirmation }
41
+ end
42
+
43
+ check_box :otp_module, label: 'Enable OTP'
44
+
45
+ end
46
+ <%- if devise? -%>
47
+
48
+ update_instance do |instance, attrs|
49
+ if attrs[:password].blank?
50
+ attrs.delete(:password)
51
+ attrs.delete(:password_confirmation) if attrs[:password_confirmation].blank?
52
+ end
53
+
54
+ instance.assign_attributes(attrs)
55
+ end
56
+
57
+ after_action on: :update do
58
+ if Devise.sign_in_after_reset_password && instance == current_user
59
+ login!(instance)
60
+ end
61
+ end
62
+ <%- end -%>
63
+ end
@@ -0,0 +1,71 @@
1
+ module Trestle
2
+ module Auth
3
+ module Otp
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+
7
+ include Rails::Generators::Migration
8
+
9
+ desc "Installs trestle-auth-otp"
10
+
11
+ argument :model, type: :string, default: "Administrator"
12
+
13
+ class_option :devise, type: :boolean, default: false, desc: "Setup trestle-auth-otp with Devise integration"
14
+
15
+ source_root File.expand_path("../templates", __FILE__)
16
+
17
+ def check_trestle_installed
18
+ unless ::File.exist?("config/initializers/trestle.rb")
19
+ raise Thor::Error, "The file config/initializers/trestle.rb does not appear to exist. Please run `trestle:install` first."
20
+ end
21
+ end
22
+
23
+ def insert_configuration
24
+ inject_into_file "config/initializers/trestle.rb", before: /^end/ do
25
+ format_configuration(template_content("basic.rb.erb"))
26
+ end
27
+ end
28
+
29
+ def generate_model
30
+ generate "trestle:auth:otp:model", model unless devise?
31
+ end
32
+
33
+ def generate_admin
34
+ generate "trestle:auth:otp:admin", model, ("--devise" if devise?)
35
+ end
36
+
37
+ def generate_migration
38
+
39
+ migration_template("migration.rb", "db/migrate/add_otp_fields.rb")
40
+
41
+ end
42
+
43
+ def devise?
44
+ options[:devise]
45
+ end
46
+
47
+ def self.next_migration_number(dirname)
48
+ next_migration_number = current_migration_number(dirname) + 1
49
+ ActiveRecord::Migration.next_migration_number(next_migration_number)
50
+ end
51
+
52
+ private
53
+ def format_configuration(source)
54
+ "\n#{source.indent(2)}\n"
55
+ end
56
+
57
+ def template_content(path, options={})
58
+ path = File.expand_path(find_in_source_paths(path.to_s))
59
+ context = options.delete(:context) || instance_eval("binding")
60
+
61
+ capturable_erb = CapturableERB.new(::File.binread(path), trim_mode: "-", eoutvar: "@output_buffer")
62
+
63
+ content = capturable_erb.tap do |erb|
64
+ erb.filename = path
65
+ end.result(context)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,11 @@
1
+ class AddOtpFields < ActiveRecord::Migration[6.0]
2
+ def up
3
+ add_column :administrators, :otp_secret_key, :string
4
+ add_column :administrators, :otp_module, :boolean, default: false
5
+ end
6
+
7
+ def down
8
+ remove_column :administrators, :otp_module
9
+ remove_column :administrators, :otp_secret_key
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Trestle
2
+ module Auth
3
+ module Otp
4
+ module Generators
5
+ class ModelGenerator < ::Rails::Generators::Base
6
+ desc "Add OTP to an Administrator model for use with trestle-auth"
7
+
8
+ argument :name, type: :string, default: "Administrator"
9
+
10
+ def inject_model_methods
11
+ inject_into_file "app/models/#{name.underscore}.rb", " include Trestle::Auth::Otp::ModelMethods\n", before: /^end/
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ require "trestle/auth/otp/version"
2
+
3
+ require "trestle"
4
+
5
+ require "active_model_otp"
6
+ require "rqrcode"
7
+
8
+ module Trestle
9
+ module Auth
10
+ module Otp
11
+ extend ActiveSupport::Autoload
12
+
13
+ autoload :ModelMethods
14
+
15
+ end
16
+ end
17
+ end
18
+
19
+ require "trestle/auth/otp/engine" if defined?(Rails)
@@ -0,0 +1,8 @@
1
+ module Trestle
2
+ module Auth
3
+ module Otp
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module Trestle
2
+ module Auth
3
+ module Otp
4
+ module ModelMethods
5
+ extend ActiveSupport::Concern
6
+ extend ActiveSupport::Autoload
7
+
8
+ included do
9
+ has_one_time_password
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module Trestle
2
+ module Auth
3
+ module Otp
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'lib/trestle/auth/otp/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "trestle-auth-otp"
5
+ spec.version = Trestle::Auth::Otp::VERSION
6
+ spec.authors = ["Emanuele Barban"]
7
+
8
+ spec.summary = "One Time Password plugin for the Trestle admin framework"
9
+ spec.homepage = "https://www.trestle.io"
10
+ spec.license = "LGPL-3.0"
11
+
12
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
13
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
14
+ end
15
+
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/McRipper/trestle-auth-otp"
22
+
23
+ spec.add_dependency "trestle", "~> 0.9.0"
24
+ spec.add_dependency "trestle-auth", "~> 0.3.0"
25
+ spec.add_dependency "active_model_otp", "~> 2.0"
26
+ spec.add_dependency "rqrcode", "~> 1.1"
27
+
28
+ spec.add_development_dependency "rspec-rails", "~> 3.0"
29
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trestle-auth-otp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Emanuele Barban
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: trestle
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: trestle-auth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: active_model_otp
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rqrcode
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".browserslistrc"
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - app/controllers/trestle/auth/sessions_controller.rb
98
+ - app/views/trestle/admin/_qr_code.html.erb
99
+ - app/views/trestle/auth/_otp.html.erb
100
+ - bin/rails
101
+ - config/initializers/trestle.rb
102
+ - gemfiles/rails-4.2.gemfile
103
+ - gemfiles/rails-5.0.gemfile
104
+ - gemfiles/rails-5.1.gemfile
105
+ - gemfiles/rails-5.2.gemfile
106
+ - gemfiles/rails-6.0.gemfile
107
+ - lib/generators/trestle/auth/otp/admin/admin_generator.rb
108
+ - lib/generators/trestle/auth/otp/admin/templates/admin.rb.erb
109
+ - lib/generators/trestle/auth/otp/install/install_generator.rb
110
+ - lib/generators/trestle/auth/otp/install/templates/basic.rb.erb
111
+ - lib/generators/trestle/auth/otp/install/templates/migration.rb
112
+ - lib/generators/trestle/auth/otp/model/model_generator.rb
113
+ - lib/trestle/auth/otp.rb
114
+ - lib/trestle/auth/otp/engine.rb
115
+ - lib/trestle/auth/otp/model_methods.rb
116
+ - lib/trestle/auth/otp/version.rb
117
+ - trestle-auth-otp.gemspec
118
+ homepage: https://www.trestle.io
119
+ licenses:
120
+ - LGPL-3.0
121
+ metadata:
122
+ homepage_uri: https://www.trestle.io
123
+ source_code_uri: https://github.com/McRipper/trestle-auth-otp
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 2.3.0
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubygems_version: 3.1.2
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: One Time Password plugin for the Trestle admin framework
143
+ test_files: []