thecore_auth_commons 3.0.3 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/Rakefile +2 -31
  4. data/app/models/user.rb +2 -53
  5. data/{lib/abilities/thecore_auth_commons.rb → config/initializers/abilities.rb} +2 -2
  6. data/config/initializers/add_to_db_migrations.rb +5 -0
  7. data/config/initializers/after_initialize.rb +12 -0
  8. data/config/initializers/concern_cancancan.rb +22 -0
  9. data/config/initializers/concern_user.rb +46 -0
  10. data/config/locales/{en.activerecord.yml → en.thecore_auth_commons.yml} +0 -1
  11. data/config/locales/{it.activerecord.yml → it.thecore_auth_commons.yml} +9 -0
  12. data/db/migrate/{20200306143408_create_users.rb → 20160208110805_devise_create_users.rb} +12 -19
  13. data/db/migrate/20160209152753_add_trackable_to_user.rb +9 -0
  14. data/db/migrate/{20200306151046_add_admin_field_to_user.rb → 20160209153229_add_admin_to_user.rb} +1 -1
  15. data/db/migrate/{20200306153125_add_lock_version_to_user.rb → 20160209153326_add_lock_version_to_user.rb} +1 -1
  16. data/db/migrate/{20200516215346_add_locked_to_user.rb → 20160209153406_add_locked_to_user.rb} +1 -1
  17. data/db/migrate/20160209153533_add_access_token_to_user.rb +5 -0
  18. data/db/migrate/20160209153811_create_roles.rb +11 -0
  19. data/db/migrate/{20200306152816_create_role_users.rb → 20160209153813_create_role_users.rb} +1 -1
  20. data/db/migrate/{20200518082821_create_permissions.rb → 20160209153816_create_permissions_chain.rb} +1 -1
  21. data/db/seeds.rb +5 -11
  22. data/lib/tasks/thecore_auth_commons_tasks.rake +8 -5
  23. data/lib/thecore/seed.rb +18 -0
  24. data/lib/thecore_auth_commons/engine.rb +0 -13
  25. data/lib/thecore_auth_commons.rb +3 -11
  26. metadata +109 -39
  27. data/MIT-LICENSE +0 -20
  28. data/app/models/ability.rb +0 -49
  29. data/config/initializers/after_initialize_thecore_auth_commons.rb +0 -10
  30. data/config/initializers/devise.rb +0 -299
  31. data/config/locales/it.permissions.yml +0 -10
  32. data/config/routes.rb +0 -5
  33. data/db/migrate/20200306152740_create_roles.rb +0 -10
  34. data/db/migrate/20200306153136_add_lock_version_to_role.rb +0 -5
  35. data/db/migrate/20210415154152_add_access_token_to_user.rb +0 -5
  36. data/lib/thecore_auth_commons_actioncontroller_concerns.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43a5cf46ed813af11c622a3dccf8dfed8a311594e090b1bd16f6c509a4e132b6
4
- data.tar.gz: 30b64a1793b8840098e794254f6c769b716c687f072d21b7e8d2249203c7a6a9
3
+ metadata.gz: 7e9c1cc8505cddf86bb6abc922c538a0d55fa571933b6158e078df3c89a477a5
4
+ data.tar.gz: 751434de07685430512faf2ff6c970c5a6a1dde6ced7e536f1d65ad7ad0acf27
5
5
  SHA512:
6
- metadata.gz: 0c49ee1ee0266fd7917263bde759464c0e2750032393bde2a1c43e07540145edb0860151585d61e2eb07164ce1162dd8505292e1d7a403aadb316f4bdf27ad49
7
- data.tar.gz: 9e74976ea1c168e1f6c4fc71ac86e193da072c3396ce282eb9d34125dcf00b23a6b24a3da4bcea032978974b73759ac0d6e337d33baa4944e232701c0a6e5268
6
+ metadata.gz: 8411d2a2141e28d778b47907d2594370c1f8c585d835e852a2f8c1ba46fba11ff9dab3abd7f3b5df269aa4149a7af4ca8055798d14ddf01cb484173695d78b1d
7
+ data.tar.gz: 8fefa012326df5192ede21c356e081b696603fef3a1979143f18c3807bf567b4660f8f98ca2fee964f005a6c9d9dbdf5068b1a1e64b8b63f421a9e4555b96084
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ThecoreAuth
1
+ # ThecoreAuthCommons
2
2
  Short description and motivation.
3
3
 
4
4
  ## Usage
@@ -8,7 +8,7 @@ How to use my plugin.
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'thecore_auth_commons'
11
+ gem "thecore_auth_commons"
12
12
  ```
13
13
 
14
14
  And then execute:
data/Rakefile CHANGED
@@ -1,32 +1,3 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require "bundler/setup"
6
2
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'ThecoreAuthCommons'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
- load 'rails/tasks/engine.rake'
19
-
20
- load 'rails/tasks/statistics.rake'
21
-
22
- require 'bundler/gem_tasks'
23
-
24
- require 'rake/testtask'
25
-
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'test'
28
- t.pattern = 'test/**/*_test.rb'
29
- t.verbose = false
30
- end
31
-
32
- task default: :test
3
+ require "bundler/gem_tasks"
data/app/models/user.rb CHANGED
@@ -1,57 +1,6 @@
1
1
  class User < ApplicationRecord
2
2
  # Include default devise modules. Others available are:
3
3
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
4
- devise :database_authenticatable
5
- devise :trackable
6
- devise :validatable
7
- # TODO: If it works, these must be added to another gem one which deal
8
- # more with sessions
9
- # devise :database_authenticatable
10
- # devise :rememberable
11
- # devise :trackable
12
- # devise :validatable
13
- # devise :timeoutable, timeout_in: 30.minutes
14
-
15
- before_validation on: :create do
16
- # If the generated uuid is not already present, then create the user with the proposed uuid
17
- # Otherwise, try to generate another one
18
- begin
19
- self.access_token = SecureRandom.uuid #urlsafe_base64(32)
20
- end while ::User.exists?(access_token: self.access_token)
21
- end
22
- # REFERENCES
23
- has_many :role_users, dependent: :destroy, inverse_of: :user
24
- has_many :roles, through: :role_users, inverse_of: :users
25
- # VALIDATIONS
26
- validates :email, uniqueness: { case_sensitive: false }, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
27
- validates :password, presence: true, on: :create
28
- validates :password_confirmation, presence: true, on: :create
29
- validate :check_password_and_confirmation_equal
30
- validates :access_token, uniqueness: true
31
- validates_each :admin do |record, attr, value|
32
- # Don't want admin == false if the current user is the only admin
33
- record.errors.add(attr, I18n.t("validation.errors.cannot_unadmin_last_admin")) if record.admin_changed? && record.admin_was == true && User.where(admin: true).count == 1
34
- end
35
- validates_each :locked do |record, attr, value|
36
- # Don't want locked == true if the current user is the only admin
37
- record.errors.add(attr, I18n.t("validation.errors.cannot_lock_last_admin")) if record.locked_changed? && record.locked_was == false && User.where(locked: false).count == 1
38
- end
39
-
40
- def display_name
41
- email
42
- end
43
-
44
- def has_role? role
45
- roles.include? role.to_s
46
- end
47
-
48
- def authenticate password
49
- self&.valid_password?(password) ? self : nil
50
- end
51
-
52
- protected
53
-
54
- def check_password_and_confirmation_equal
55
- errors.add(:password, I18n.t("validation.errors.password_and_confirm_must_be_the_same")) unless password == password_confirmation
56
- end
4
+ devise :database_authenticatable, :registerable,
5
+ :recoverable, :rememberable, :validatable
57
6
  end
@@ -9,8 +9,8 @@ module Abilities
9
9
  if user.admin?
10
10
  # Admins' abiities
11
11
  can :manage, :all # only allow admin users to access Rails Admin
12
- cannot :destroy, User do |u|
13
- # prevents killing himself
12
+ # prevents killing himself
13
+ cannot :destroy, ::User do |u|
14
14
  u.id == user.id
15
15
  end
16
16
  end
@@ -0,0 +1,5 @@
1
+ # This method defines the migrations paths for the engine and adds them to the migrations paths of
2
+ # the parent Rails app by using ActiveRecord::Migrator.migrations_paths.concat.
3
+ # migrations_paths = [File.expand_path("../../db/migrate", __dir__)]
4
+ # ActiveRecord::Migrator.migrations_paths.concat(migrations_paths)
5
+ Rails.application.config.paths['db/migrate'] << File.expand_path("../../db/migrate", __dir__)
@@ -0,0 +1,12 @@
1
+ Rails.application.configure do
2
+ config.after_initialize do
3
+ # In development be sure to load all the namespaces
4
+ # in order to have working reflection and meta-programming.
5
+ Zeitwerk::Loader.eager_load_all if Rails.env.development?
6
+
7
+ Ability.send(:include, ThecoreAuthCommonsCanCanCanConcern)
8
+ User.send(:include, ThecoreAuthCommonsUserConcern)
9
+ User.devise_modules.delete(:recoverable) if ThecoreSettings::Setting.where(ns: :devise, key: :recoverable).first.present? && ThecoreSettings::Setting.where(ns: :devise, key: :recoverable).first.raw == "disable"
10
+ User.devise_modules.delete(:registerable) if ThecoreSettings::Setting.where(ns: :devise, key: :registerable).first.present? && ThecoreSettings::Setting.where(ns: :devise, key: :registerable).first.raw == "disable"
11
+ end
12
+ end
@@ -0,0 +1,22 @@
1
+ module ThecoreAuthCommonsCanCanCanConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ def initialize(user)
6
+ # This will always be the first Ability, since the abilities are "last wins"
7
+ self.merge Abilities::ThecoreAuthCommons.new user
8
+ # Other Abilities
9
+ Abilities.constants(false).each do |ability|
10
+ unless ability.to_s == "ThecoreAuthCommons"
11
+ const = Abilities.const_get(ability)
12
+ self.merge const.new(user) if const.is_a? Class
13
+ end
14
+ end
15
+ # Overrides from the database defined permissions
16
+ ::Permission.joins(roles: :users).where(users: {id: user.id}).order(:id).each do |permission|
17
+ # E.g. can :manage, :all
18
+ self.send(permission.predicate.name.to_sym, permission.action.name.to_sym, (permission.target.name.classify.constantize rescue permission.target.name.to_sym))
19
+ end unless user.blank?
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,46 @@
1
+ module ThecoreAuthCommonsUserConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_validation on: :create do
6
+ # If the generated uuid is not already present, then create the user with the proposed uuid
7
+ # Otherwise, try to generate another one
8
+ begin
9
+ self.access_token = SecureRandom.uuid #urlsafe_base64(32)
10
+ end while ::User.exists?(access_token: self.access_token)
11
+ end
12
+ # REFERENCES
13
+ has_many :role_users, dependent: :destroy, inverse_of: :user
14
+ has_many :roles, through: :role_users, inverse_of: :users
15
+ # VALIDATIONS
16
+ validates :email, uniqueness: { case_sensitive: false }, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
17
+ validates :password, presence: true, on: :create
18
+ validates :password_confirmation, presence: true, on: :create
19
+ validate :check_password_and_confirmation_equal
20
+ validates :access_token, uniqueness: true
21
+ validates_each :admin do |record, attr, value|
22
+ # Don't want admin == false if the current user is the only admin
23
+ record.errors.add(attr, I18n.t("validation.errors.cannot_unadmin_last_admin")) if record.admin_changed? && record.admin_was == true && User.where(admin: true).count == 1
24
+ end
25
+ validates_each :locked do |record, attr, value|
26
+ # Don't want locked == true if the current user is the only admin
27
+ record.errors.add(attr, I18n.t("validation.errors.cannot_lock_last_admin")) if record.locked_changed? && record.locked_was == false && User.where(locked: false).count == 1
28
+ end
29
+
30
+ def display_name
31
+ email
32
+ end
33
+
34
+ def has_role? role
35
+ roles.include? role.to_s
36
+ end
37
+
38
+ def authenticate password
39
+ self&.valid_password?(password) ? self : nil
40
+ end
41
+
42
+ def check_password_and_confirmation_equal
43
+ errors.add(:password, I18n.t("validation.errors.password_and_confirm_must_be_the_same")) unless password == password_confirmation
44
+ end
45
+ end
46
+ end
@@ -8,4 +8,3 @@ en:
8
8
  user: Section to manage users.
9
9
  role: Section to manage Roles
10
10
  permission: Section to manage Permissions
11
-
@@ -36,3 +36,12 @@ it:
36
36
  user: In questa sezione dell'applicazione potete cercare nella lista degli utenti in diversi modi usando i filtri o ordinare la lista secondo diversi campi.
37
37
  role: In questa sezione si possono creare dei ruoli da usare nell'RBAC gestito dai file abilities, per definire le autorizzazioni CRUD e non solo.
38
38
  permission: Il predicato definisce se è un permesso di poter fare o non fare, l'azione è il tipo definisce cosa si possa fare o non fare, mentre il modello definisce su chi.
39
+ permissions:
40
+ predicates:
41
+ can: Può
42
+ cannot: Non può
43
+ actions:
44
+ manage: Gestire
45
+ read: Leggere
46
+ update: Modificare
47
+ destroy: Eliminare
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateUsers < ActiveRecord::Migration[6.0]
4
- def self.up
3
+ class DeviseCreateUsers < ActiveRecord::Migration[7.0]
4
+ def change
5
5
  create_table :users do |t|
6
6
  ## Database authenticatable
7
7
  t.string :email, null: false, default: ""
8
8
  t.string :encrypted_password, null: false, default: ""
9
9
 
10
10
  ## Recoverable
11
- # t.string :reset_password_token
12
- # t.datetime :reset_password_sent_at
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
13
 
14
14
  ## Rememberable
15
- # t.datetime :remember_created_at
15
+ t.datetime :remember_created_at
16
16
 
17
- # Trackable
18
- t.integer :sign_in_count, default: 0, null: false
19
- t.datetime :current_sign_in_at
20
- t.datetime :last_sign_in_at
21
- t.string :current_sign_in_ip
22
- t.string :last_sign_in_ip
17
+ ## Trackable
18
+ # t.integer :sign_in_count, default: 0, null: false
19
+ # t.datetime :current_sign_in_at
20
+ # t.datetime :last_sign_in_at
21
+ # t.string :current_sign_in_ip
22
+ # t.string :last_sign_in_ip
23
23
 
24
24
  ## Confirmable
25
25
  # t.string :confirmation_token
@@ -33,19 +33,12 @@ class CreateUsers < ActiveRecord::Migration[6.0]
33
33
  # t.datetime :locked_at
34
34
 
35
35
 
36
- # Uncomment below if timestamps were not included in your original model.
37
36
  t.timestamps null: false
38
37
  end
39
38
 
40
39
  add_index :users, :email, unique: true
41
- # add_index :users, :reset_password_token, unique: true
40
+ add_index :users, :reset_password_token, unique: true
42
41
  # add_index :users, :confirmation_token, unique: true
43
42
  # add_index :users, :unlock_token, unique: true
44
43
  end
45
-
46
- def self.down
47
- # By default, we don't want to make any assumption about how to roll back a migration when your
48
- # model already existed. Please edit below which fields you would like to remove in this migration.
49
- raise ActiveRecord::IrreversibleMigration
50
- end
51
44
  end
@@ -0,0 +1,9 @@
1
+ class AddTrackableToUser < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :users, :sign_in_count, :bigint, default: 0, null: false
4
+ add_column :users, :current_sign_in_at, :datetime
5
+ add_column :users, :last_sign_in_at, :datetime
6
+ add_column :users, :current_sign_in_ip, :string
7
+ add_column :users, :last_sign_in_ip, :string
8
+ end
9
+ end
@@ -1,4 +1,4 @@
1
- class AddAdminFieldToUser < ActiveRecord::Migration[6.0]
1
+ class AddAdminToUser < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  add_column :users, :admin, :boolean, null: false, default: false
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddLockVersionToUser < ActiveRecord::Migration[6.0]
1
+ class AddLockVersionToUser < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  add_column :users, :lock_version, :bigint
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddLockedToUser < ActiveRecord::Migration[6.0]
1
+ class AddLockedToUser < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  add_column :users, :locked, :boolean, null: false, default: false
4
4
  end
@@ -0,0 +1,5 @@
1
+ class AddAccessTokenToUser < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :users, :encrypted_access_token, :string
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class CreateRoles < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :roles do |t|
4
+ t.string :name
5
+ t.bigint :lock_version
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :roles, :name, unique: true
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- class CreateRoleUsers < ActiveRecord::Migration[6.0]
1
+ class CreateRoleUsers < ActiveRecord::Migration[7.0]
2
2
  def change
3
3
  create_table :role_users do |t|
4
4
  t.references :role, null: false, foreign_key: true
@@ -1,4 +1,4 @@
1
- class CreatePermissions < ActiveRecord::Migration[6.0]
1
+ class CreatePermissionsChain < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  # Predicates
4
4
  create_table :predicates do |t|
data/db/seeds.rb CHANGED
@@ -6,20 +6,11 @@ unless User.where(admin: true).exists?
6
6
  u = User.find_or_initialize_by(email: email)
7
7
  u.username = "Administrator" if u.respond_to? :username=
8
8
  u.password = u.password_confirmation = psswd
9
+ u.encrypted_access_token = User.new(:password => SecureRandom.uuid).encrypted_password
9
10
  u.admin = true
10
11
  u.save(validate: false)
11
12
  end
12
13
 
13
- # If there are previous users without the access_token, create it:
14
- User.all.each do |u|
15
- if u.access_token.blank?
16
- begin
17
- u.access_token = SecureRandom.uuid #urlsafe_base64(32)
18
- end while ::User.exists?(access_token: u.access_token)
19
- u.save(validate: false)
20
- end
21
- end
22
-
23
14
  @values = {
24
15
  predicates: %i[can cannot],
25
16
  actions: %i[manage create read update destroy],
@@ -34,4 +25,7 @@ end
34
25
 
35
26
  fill :predicates
36
27
  fill :actions
37
- fill :targets
28
+ fill :targets
29
+
30
+ ThecoreSettings::Setting.create(ns: :devise, key: :registerable, raw: "disable")
31
+ ThecoreSettings::Setting.create(ns: :devise, key: :recoverable, raw: "disable")
@@ -1,12 +1,8 @@
1
- # desc "Explaining what the task does"
2
- # task :thecore_auth_commons do
3
- # # Task goes here
4
- # end
5
1
  namespace :thecore do
6
2
  namespace :db do
7
3
  desc "Load seeds from thecore engines seed files, it also runs rails db:seed as last action."
8
4
  task seed: :environment do
9
- Thecore::Base.thecore_engines.each { |engine| engine.send :load_seed }
5
+ Rails::Engine.subclasses.each { |engine| engine.send :load_seed }
10
6
  Rake::Task["db:seed"].reenable
11
7
  Rake::Task["db:seed"].invoke
12
8
  end
@@ -24,5 +20,12 @@ namespace :thecore do
24
20
  Rake::Task["thecore:db:init"].reenable
25
21
  Rake::Task["thecore:db:init"].invoke
26
22
  end
23
+ desc "Deletes DB if not exists, then init it with all Thecore compatible seeds."
24
+ task reset: :environment do
25
+ Rake::Task["db:drop"].reenable
26
+ Rake::Task["db:drop"].invoke
27
+ Rake::Task["thecore:db:init"].reenable
28
+ Rake::Task["thecore:db:init"].invoke
29
+ end
27
30
  end
28
31
  end
@@ -0,0 +1,18 @@
1
+ # Extensions to help during seeding of ThecoreSettings
2
+ module Thecore
3
+ class Seed
4
+ def self.save_setting ns, setting, value
5
+ puts "Saving setting if nil #{ns}: #{setting} = #{value}"
6
+ if ::Settings.ns(ns)[setting].blank?
7
+ ::Settings.ns(ns)[setting] if value.blank?
8
+ ::Settings.ns(ns)[setting] = value unless value.blank?
9
+ end
10
+ end
11
+
12
+ def self.delete_setting ns, setting
13
+ puts "Removing setting #{ns}: #{setting}"
14
+ ThecoreSettings::Setting.where(ns: ns, key: setting).destroy_all
15
+ end
16
+ end
17
+ end
18
+
@@ -1,17 +1,4 @@
1
1
  module ThecoreAuthCommons
2
2
  class Engine < ::Rails::Engine
3
- # https://stackoverflow.com/questions/12161376/rails-3-2-adding-seed-tasks-from-a-mountable-engine
4
-
5
- initializer 'thecore_auth_commons.add_to_migrations' do |app|
6
- # Adds the list of Thecore Engines, so to manage seeds loading, i.e.:
7
- # Thecore::Base.thecore_engines.each { |engine| engine.load_seed }
8
- Thecore::Base.thecore_engines << self.class
9
- unless app.root.to_s.match root.to_s
10
- # APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
11
- config.paths['db/migrate'].expanded.each do |expanded_path|
12
- app.config.paths['db/migrate'] << expanded_path
13
- end
14
- end
15
- end
16
3
  end
17
4
  end
@@ -2,20 +2,12 @@ require 'devise'
2
2
  require 'cancancan'
3
3
  require 'kaminari'
4
4
  require 'activerecord-nulldb-adapter'
5
- # require 'active_record/hierarchical_query'
6
- require 'abilities/thecore_auth_commons'
5
+ require "thecore_settings"
7
6
 
8
7
  require "thecore_auth_commons/engine"
9
8
 
9
+ require "thecore/seed"
10
+
10
11
  module ThecoreAuthCommons
11
12
  # Your code goes here...
12
13
  end
13
-
14
- module Thecore
15
- class Base
16
- @@thecore_engines = []
17
- def self.thecore_engines
18
- @@thecore_engines
19
- end
20
- end
21
- end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_auth_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-06 00:00:00.000000000 Z
11
+ date: 2023-02-11 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: devise
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +66,90 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thecore_settings
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.22'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.22'
97
+ - !ruby/object:Gem::Dependency
98
+ name: database_cleaner
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: factory_bot
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '6.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '6.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.45'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.45'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.18'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.18'
83
153
  - !ruby/object:Gem::Dependency
84
154
  name: sqlite3
85
155
  requirement: !ruby/object:Gem::Requirement
@@ -97,15 +167,13 @@ dependencies:
97
167
  description: Provides common User and Role models to attach Authentication and Authorization
98
168
  via your preferred gem.
99
169
  email:
100
- - gabriele.tassoni@gmail.com
170
+ - g.tassoni@bancolini.com
101
171
  executables: []
102
172
  extensions: []
103
173
  extra_rdoc_files: []
104
174
  files:
105
- - MIT-LICENSE
106
175
  - README.md
107
176
  - Rakefile
108
- - app/models/ability.rb
109
177
  - app/models/action.rb
110
178
  - app/models/permission.rb
111
179
  - app/models/permission_role.rb
@@ -114,33 +182,35 @@ files:
114
182
  - app/models/role_user.rb
115
183
  - app/models/target.rb
116
184
  - app/models/user.rb
117
- - config/initializers/after_initialize_thecore_auth_commons.rb
118
- - config/initializers/devise.rb
119
- - config/locales/en.activerecord.yml
120
- - config/locales/it.activerecord.yml
121
- - config/locales/it.permissions.yml
122
- - config/routes.rb
123
- - db/migrate/20200306143408_create_users.rb
124
- - db/migrate/20200306151046_add_admin_field_to_user.rb
125
- - db/migrate/20200306152740_create_roles.rb
126
- - db/migrate/20200306152816_create_role_users.rb
127
- - db/migrate/20200306153125_add_lock_version_to_user.rb
128
- - db/migrate/20200306153136_add_lock_version_to_role.rb
129
- - db/migrate/20200516215346_add_locked_to_user.rb
130
- - db/migrate/20200518082821_create_permissions.rb
131
- - db/migrate/20210415154152_add_access_token_to_user.rb
185
+ - config/initializers/abilities.rb
186
+ - config/initializers/add_to_db_migrations.rb
187
+ - config/initializers/after_initialize.rb
188
+ - config/initializers/concern_cancancan.rb
189
+ - config/initializers/concern_user.rb
190
+ - config/locales/en.thecore_auth_commons.yml
191
+ - config/locales/it.thecore_auth_commons.yml
192
+ - db/migrate/20160208110805_devise_create_users.rb
193
+ - db/migrate/20160209152753_add_trackable_to_user.rb
194
+ - db/migrate/20160209153229_add_admin_to_user.rb
195
+ - db/migrate/20160209153326_add_lock_version_to_user.rb
196
+ - db/migrate/20160209153406_add_locked_to_user.rb
197
+ - db/migrate/20160209153533_add_access_token_to_user.rb
198
+ - db/migrate/20160209153811_create_roles.rb
199
+ - db/migrate/20160209153813_create_role_users.rb
200
+ - db/migrate/20160209153816_create_permissions_chain.rb
132
201
  - db/seeds.rb
133
- - lib/abilities/thecore_auth_commons.rb
134
202
  - lib/tasks/thecore_auth_commons_tasks.rake
203
+ - lib/thecore/seed.rb
135
204
  - lib/thecore_auth_commons.rb
136
205
  - lib/thecore_auth_commons/engine.rb
137
206
  - lib/thecore_auth_commons/version.rb
138
- - lib/thecore_auth_commons_actioncontroller_concerns.rb
139
207
  homepage: https://github.com/gabrieletassoni/thecore_auth_commons
140
- licenses:
141
- - MIT
208
+ licenses: []
142
209
  metadata:
143
210
  allowed_push_host: https://rubygems.org
211
+ homepage_uri: https://github.com/gabrieletassoni/thecore_auth_commons
212
+ source_code_uri: https://github.com/gabrieletassoni/thecore_auth_commons
213
+ changelog_uri: https://github.com/gabrieletassoni/thecore_auth_commons/blob/master/CHANGELOG.md
144
214
  post_install_message:
145
215
  rdoc_options: []
146
216
  require_paths:
@@ -156,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
226
  - !ruby/object:Gem::Version
157
227
  version: '0'
158
228
  requirements: []
159
- rubygems_version: 3.4.1
229
+ rubygems_version: 3.4.6
160
230
  signing_key:
161
231
  specification_version: 4
162
232
  summary: Common Auth methods and models to be used in thecore components.
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2020
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Ability
4
- include CanCan::Ability
5
-
6
- def initialize(user)
7
- # Define abilities for the passed in user here. For example:
8
- #
9
- # user ||= User.new # guest user (not logged in)
10
- # if user.admin?
11
- # can :manage, :all
12
- # else
13
- # can :read, :all
14
- # end
15
- #
16
- # The first argument to `can` is the action you are giving the user
17
- # permission to do.
18
- # If you pass :manage it will apply to every action. Other common actions
19
- # here are :read, :create, :update and :destroy.
20
- #
21
- # The second argument is the resource the user can perform the action on.
22
- # If you pass :all it will apply to every resource. Otherwise pass a Ruby
23
- # class of the resource.
24
- #
25
- # The third argument is an optional hash of conditions to further filter the
26
- # objects.
27
- # For example, here the user can only update published articles.
28
- #
29
- # can :update, Article, :published => true
30
- #
31
- # See the wiki for details:
32
- # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
33
-
34
- # This will always be the first Ability, since the abilities are "last wins"
35
- self.merge Abilities::ThecoreAuthCommons.new user
36
- # Other Abilities
37
- Abilities.constants(false).each do |ability|
38
- unless ability.to_s == "ThecoreAuthCommons"
39
- const = Abilities.const_get(ability)
40
- self.merge const.new(user) if const.is_a? Class
41
- end
42
- end
43
- # Overrides from the database defined permissions
44
- ::Permission.joins(roles: :users).where(users: {id: user.id}).order(:id).each do |permission|
45
- # E.g. can :manage, :all
46
- self.send(permission.predicate.name.to_sym, permission.action.name.to_sym, (permission.target.name.classify.constantize rescue permission.target.name.to_sym))
47
- end unless user.blank?
48
- end
49
- end
@@ -1,10 +0,0 @@
1
- require 'thecore_auth_commons_actioncontroller_concerns'
2
-
3
- # App Config
4
- Rails.application.configure do
5
- config.after_initialize do
6
- # In development be sure to load all the namespaces
7
- # in order to have working reflection and meta-programming.
8
- Zeitwerk::Loader.eager_load_all if Rails.env.development?
9
- end
10
- end
@@ -1,299 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Use this hook to configure devise mailer, warden hooks and so forth.
4
- # Many of these configuration options can be set straight in your model.
5
- Devise.setup do |config|
6
- # The secret key used by Devise. Devise uses this key to generate
7
- # random tokens. Changing this key will render invalid all existing
8
- # confirmation, reset password and unlock tokens in the database.
9
- # Devise will use the `secret_key_base` as its `secret_key`
10
- # by default. You can change it below and use your own secret key.
11
- # config.secret_key = '3b97afd4baabfd5eb8c118ee25efe06017a8319dd5da4f39b287d20948ff844facb0b9c8daff13b7b437b92868aae71797686dcae3704e45e92d3b37094c9d3d'
12
-
13
- # ==> Controller configuration
14
- # Configure the parent class to the devise controllers.
15
- # config.parent_controller = 'DeviseController'
16
-
17
- # ==> Mailer Configuration
18
- # Configure the e-mail address which will be shown in Devise::Mailer,
19
- # note that it will be overwritten if you use your own mailer class
20
- # with default "from" parameter.
21
- config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
22
-
23
- # Configure the class responsible to send e-mails.
24
- # config.mailer = 'Devise::Mailer'
25
-
26
- # Configure the parent class responsible to send e-mails.
27
- # config.parent_mailer = 'ActionMailer::Base'
28
-
29
- # ==> ORM configuration
30
- # Load and configure the ORM. Supports :active_record (default) and
31
- # :mongoid (bson_ext recommended) by default. Other ORMs may be
32
- # available as additional gems.
33
- require 'devise/orm/active_record'
34
-
35
- # ==> Configuration for any authentication mechanism
36
- # Configure which keys are used when authenticating a user. The default is
37
- # just :email. You can configure it to use [:username, :subdomain], so for
38
- # authenticating a user, both parameters are required. Remember that those
39
- # parameters are used only when authenticating and not when retrieving from
40
- # session. If you need permissions, you should implement that in a before filter.
41
- # You can also supply a hash where the value is a boolean determining whether
42
- # or not authentication should be aborted when the value is not present.
43
- # config.authentication_keys = [:email]
44
-
45
- # Configure parameters from the request object used for authentication. Each entry
46
- # given should be a request method and it will automatically be passed to the
47
- # find_for_authentication method and considered in your model lookup. For instance,
48
- # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
49
- # The same considerations mentioned for authentication_keys also apply to request_keys.
50
- # config.request_keys = []
51
-
52
- # Configure which authentication keys should be case-insensitive.
53
- # These keys will be downcased upon creating or modifying a user and when used
54
- # to authenticate or find a user. Default is :email.
55
- config.case_insensitive_keys = [:email]
56
-
57
- # Configure which authentication keys should have whitespace stripped.
58
- # These keys will have whitespace before and after removed upon creating or
59
- # modifying a user and when used to authenticate or find a user. Default is :email.
60
- config.strip_whitespace_keys = [:email]
61
-
62
- # Tell if authentication through request.params is enabled. True by default.
63
- # It can be set to an array that will enable params authentication only for the
64
- # given strategies, for example, `config.params_authenticatable = [:database]` will
65
- # enable it only for database (email + password) authentication.
66
- # config.params_authenticatable = true
67
-
68
- # Tell if authentication through HTTP Auth is enabled. False by default.
69
- # It can be set to an array that will enable http authentication only for the
70
- # given strategies, for example, `config.http_authenticatable = [:database]` will
71
- # enable it only for database authentication. The supported strategies are:
72
- # :database = Support basic authentication with authentication key + password
73
- # config.http_authenticatable = false
74
-
75
- # If 401 status code should be returned for AJAX requests. True by default.
76
- # config.http_authenticatable_on_xhr = true
77
-
78
- # The realm used in Http Basic Authentication. 'Application' by default.
79
- # config.http_authentication_realm = 'Application'
80
-
81
- # It will change confirmation, password recovery and other workflows
82
- # to behave the same regardless if the e-mail provided was right or wrong.
83
- # Does not affect registerable.
84
- # config.paranoid = true
85
-
86
- # By default Devise will store the user in session. You can skip storage for
87
- # particular strategies by setting this option.
88
- # Notice that if you are skipping storage for all authentication paths, you
89
- # may want to disable generating routes to Devise's sessions controller by
90
- # passing skip: :sessions to `devise_for` in your config/routes.rb
91
- config.skip_session_storage = [:http_auth]
92
-
93
- # By default, Devise cleans up the CSRF token on authentication to
94
- # avoid CSRF token fixation attacks. This means that, when using AJAX
95
- # requests for sign in and sign up, you need to get a new CSRF token
96
- # from the server. You can disable this option at your own risk.
97
- # config.clean_up_csrf_token_on_authentication = true
98
-
99
- # When false, Devise will not attempt to reload routes on eager load.
100
- # This can reduce the time taken to boot the app but if your application
101
- # requires the Devise mappings to be loaded during boot time the application
102
- # won't boot properly.
103
- # config.reload_routes = true
104
-
105
- # ==> Configuration for :database_authenticatable
106
- # For bcrypt, this is the cost for hashing the password and defaults to 11. If
107
- # using other algorithms, it sets how many times you want the password to be hashed.
108
- #
109
- # Limiting the stretches to just one in testing will increase the performance of
110
- # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
111
- # a value less than 10 in other environments. Note that, for bcrypt (the default
112
- # algorithm), the cost increases exponentially with the number of stretches (e.g.
113
- # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
114
- config.stretches = Rails.env.test? ? 1 : 11
115
-
116
- # Set up a pepper to generate the hashed password.
117
- # config.pepper = 'ec0d64f5b4e32673fdc396433677d4f6b61aaf2ef6081b99b2cc8612f3c24556361eeea86ab2799772618f30e417c965491737a553b03d3e558db85256569971'
118
-
119
- # Send a notification to the original email when the user's email is changed.
120
- # config.send_email_changed_notification = false
121
-
122
- # Send a notification email when the user's password is changed.
123
- # config.send_password_change_notification = false
124
-
125
- # ==> Configuration for :confirmable
126
- # A period that the user is allowed to access the website even without
127
- # confirming their account. For instance, if set to 2.days, the user will be
128
- # able to access the website for two days without confirming their account,
129
- # access will be blocked just in the third day.
130
- # You can also set it to nil, which will allow the user to access the website
131
- # without confirming their account.
132
- # Default is 0.days, meaning the user cannot access the website without
133
- # confirming their account.
134
- # config.allow_unconfirmed_access_for = 2.days
135
-
136
- # A period that the user is allowed to confirm their account before their
137
- # token becomes invalid. For example, if set to 3.days, the user can confirm
138
- # their account within 3 days after the mail was sent, but on the fourth day
139
- # their account can't be confirmed with the token any more.
140
- # Default is nil, meaning there is no restriction on how long a user can take
141
- # before confirming their account.
142
- # config.confirm_within = 3.days
143
-
144
- # If true, requires any email changes to be confirmed (exactly the same way as
145
- # initial account confirmation) to be applied. Requires additional unconfirmed_email
146
- # db field (see migrations). Until confirmed, new email is stored in
147
- # unconfirmed_email column, and copied to email column on successful confirmation.
148
- config.reconfirmable = true
149
-
150
- # Defines which key will be used when confirming an account
151
- # config.confirmation_keys = [:email]
152
-
153
- # ==> Configuration for :rememberable
154
- # The time the user will be remembered without asking for credentials again.
155
- # config.remember_for = 2.weeks
156
-
157
- # Invalidates all the remember me tokens when the user signs out.
158
- config.expire_all_remember_me_on_sign_out = true
159
-
160
- # If true, extends the user's remember period when remembered via cookie.
161
- # config.extend_remember_period = false
162
-
163
- # Options to be passed to the created cookie. For instance, you can set
164
- # secure: true in order to force SSL only cookies.
165
- # config.rememberable_options = {}
166
-
167
- # ==> Configuration for :validatable
168
- # Range for password length.
169
- config.password_length = 6..128
170
-
171
- # Email regex used to validate email formats. It simply asserts that
172
- # one (and only one) @ exists in the given string. This is mainly
173
- # to give user feedback and not to assert the e-mail validity.
174
- config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
175
-
176
- # ==> Configuration for :timeoutable
177
- # The time you want to timeout the user session without activity. After this
178
- # time the user will be asked for credentials again. Default is 30 minutes.
179
- # config.timeout_in = 30.minutes
180
-
181
- # ==> Configuration for :lockable
182
- # Defines which strategy will be used to lock an account.
183
- # :failed_attempts = Locks an account after a number of failed attempts to sign in.
184
- # :none = No lock strategy. You should handle locking by yourself.
185
- # config.lock_strategy = :failed_attempts
186
-
187
- # Defines which key will be used when locking and unlocking an account
188
- # config.unlock_keys = [:email]
189
-
190
- # Defines which strategy will be used to unlock an account.
191
- # :email = Sends an unlock link to the user email
192
- # :time = Re-enables login after a certain amount of time (see :unlock_in below)
193
- # :both = Enables both strategies
194
- # :none = No unlock strategy. You should handle unlocking by yourself.
195
- # config.unlock_strategy = :both
196
-
197
- # Number of authentication tries before locking an account if lock_strategy
198
- # is failed attempts.
199
- # config.maximum_attempts = 20
200
-
201
- # Time interval to unlock the account if :time is enabled as unlock_strategy.
202
- # config.unlock_in = 1.hour
203
-
204
- # Warn on the last attempt before the account is locked.
205
- # config.last_attempt_warning = true
206
-
207
- # ==> Configuration for :recoverable
208
- #
209
- # Defines which key will be used when recovering the password for an account
210
- # config.reset_password_keys = [:email]
211
-
212
- # Time interval you can reset your password with a reset password key.
213
- # Don't put a too small interval or your users won't have the time to
214
- # change their passwords.
215
- config.reset_password_within = 6.hours
216
-
217
- # When set to false, does not sign a user in automatically after their password is
218
- # reset. Defaults to true, so a user is signed in automatically after a reset.
219
- # config.sign_in_after_reset_password = true
220
-
221
- # ==> Configuration for :encryptable
222
- # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
223
- # You can use :sha1, :sha512 or algorithms from others authentication tools as
224
- # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
225
- # for default behavior) and :restful_authentication_sha1 (then you should set
226
- # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
227
- #
228
- # Require the `devise-encryptable` gem when using anything other than bcrypt
229
- # config.encryptor = :sha512
230
-
231
- # ==> Scopes configuration
232
- # Turn scoped views on. Before rendering "sessions/new", it will first check for
233
- # "users/sessions/new". It's turned off by default because it's slower if you
234
- # are using only default views.
235
- # config.scoped_views = false
236
-
237
- # Configure the default scope given to Warden. By default it's the first
238
- # devise role declared in your routes (usually :user).
239
- # config.default_scope = :user
240
-
241
- # Set this configuration to false if you want /users/sign_out to sign out
242
- # only the current scope. By default, Devise signs out all scopes.
243
- # config.sign_out_all_scopes = true
244
-
245
- # ==> Navigation configuration
246
- # Lists the formats that should be treated as navigational. Formats like
247
- # :html, should redirect to the sign in page when the user does not have
248
- # access, but formats like :xml or :json, should return 401.
249
- #
250
- # If you have any extra navigational formats, like :iphone or :mobile, you
251
- # should add them to the navigational formats lists.
252
- #
253
- # The "*/*" below is required to match Internet Explorer requests.
254
- # config.navigational_formats = ['*/*', :html]
255
-
256
- # The default HTTP method used to sign out a resource. Default is :delete.
257
- config.sign_out_via = :delete
258
-
259
- # ==> OmniAuth
260
- # Add a new OmniAuth provider. Check the wiki for more information on setting
261
- # up on your models and hooks.
262
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
263
-
264
- # ==> Warden configuration
265
- # If you want to use other strategies, that are not supported by Devise, or
266
- # change the failure app, you can configure them inside the config.warden block.
267
- #
268
- # config.warden do |manager|
269
- # manager.intercept_401 = false
270
- # manager.default_strategies(scope: :user).unshift :some_external_strategy
271
- # end
272
-
273
- # ==> Mountable engine configurations
274
- # When using Devise inside an engine, let's call it `MyEngine`, and this engine
275
- # is mountable, there are some extra configurations to be taken into account.
276
- # The following options are available, assuming the engine is mounted as:
277
- #
278
- # mount MyEngine, at: '/my_engine'
279
- #
280
- # The router that invoked `devise_for`, in the example above, would be:
281
- # config.router_name = :my_engine
282
- #
283
- # When using OmniAuth, Devise cannot automatically set OmniAuth path,
284
- # so you need to do it manually. For the users scope, it would be:
285
- # config.omniauth_path_prefix = '/my_engine/users/auth'
286
-
287
- # ==> Turbolinks configuration
288
- # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
289
- #
290
- # ActiveSupport.on_load(:devise_failure_app) do
291
- # include Turbolinks::Controller
292
- # end
293
-
294
- # ==> Configuration for :registerable
295
-
296
- # When set to false, does not sign a user in automatically after their password is
297
- # changed. Defaults to true, so a user is signed in automatically after changing a password.
298
- # config.sign_in_after_change_password = true
299
- end
@@ -1,10 +0,0 @@
1
- it:
2
- permissions:
3
- predicates:
4
- can: Può
5
- cannot: Non può
6
- actions:
7
- manage: Gestire
8
- read: Leggere
9
- update: Modificare
10
- destroy: Eliminare
data/config/routes.rb DELETED
@@ -1,5 +0,0 @@
1
- Rails.application.routes.draw do
2
- devise_for :users
3
- # Look at https://altalogy.com/blog/rails-6-user-accounts-with-3-types-of-roles/
4
- # For controller
5
- end
@@ -1,10 +0,0 @@
1
- class CreateRoles < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :roles do |t|
4
- t.string :name
5
-
6
- t.timestamps
7
- end
8
- add_index :roles, :name
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- class AddLockVersionToRole < ActiveRecord::Migration[6.0]
2
- def change
3
- add_column :roles, :lock_version, :bigint
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddAccessTokenToUser < ActiveRecord::Migration[6.0]
2
- def change
3
- add_column :users, :access_token, :uuid
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- module ThecoreAuthCommonsActioncontrollerConcerns
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- include HttpAcceptLanguage::AutoLocale
6
- end
7
- end