chaltron 1.1.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/chaltron.js +0 -18
  3. data/app/assets/javascripts/chaltron/core.js.erb +62 -0
  4. data/app/assets/javascripts/chaltron/datatables.js +69 -0
  5. data/app/assets/javascripts/chaltron/flash_messages.js +14 -0
  6. data/app/assets/javascripts/chaltron/ldap_create.js +44 -0
  7. data/app/assets/javascripts/chaltron/locales/en.json +25 -0
  8. data/app/assets/javascripts/chaltron/locales/it.json +25 -0
  9. data/app/assets/javascripts/chaltron/navbar.js +86 -0
  10. data/app/assets/stylesheets/chaltron.scss +0 -27
  11. data/app/helpers/chaltron/ldap_helper.rb +9 -0
  12. data/app/views/chaltron/ldap/_entry.html.erb +3 -1
  13. data/app/views/chaltron/ldap/multi_new.html.erb +6 -2
  14. data/config/initializers/devise.rb +259 -255
  15. data/config/initializers/warden.rb +27 -25
  16. data/config/routes.rb +1 -1
  17. data/lib/chaltron.rb +0 -1
  18. data/lib/chaltron/engine.rb +17 -18
  19. data/lib/chaltron/form_builder/bootstrap_form.rb +23 -0
  20. data/lib/chaltron/ldap/connection.rb +154 -152
  21. data/lib/chaltron/version.rb +1 -1
  22. data/lib/generators/chaltron/install_generator.rb +59 -5
  23. data/lib/generators/chaltron/templates/Procfile +2 -0
  24. data/lib/generators/chaltron/templates/app/assets/javascripts/{home.js.coffee → home.coffee} +0 -0
  25. data/lib/generators/chaltron/templates/app/assets/stylesheets/chaltron_custom.scss +24 -10
  26. data/lib/generators/chaltron/templates/app/assets/stylesheets/datatables.scss +2 -0
  27. data/lib/generators/chaltron/templates/app/views/layouts/application.html.erb +2 -2
  28. data/lib/generators/chaltron/templates/config/navigation.rb +8 -8
  29. metadata +13 -234
  30. data/app/assets/javascripts/chaltron/datatables.js.coffee +0 -103
  31. data/app/assets/javascripts/chaltron/localization.js.coffee +0 -59
  32. data/app/assets/javascripts/chaltron/main.js.coffee +0 -7
  33. data/app/assets/javascripts/chaltron/navbar.js.coffee +0 -62
  34. data/app/assets/javascripts/dataTables/dataTables.bootstrap4.min.js +0 -8
  35. data/lib/chaltron/bootstrap_form.rb +0 -21
  36. data/lib/generators/chaltron/install/templates/Procfile +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c903358c42ce7e75e0ecae0e4f87b025e9909f769ec87c7644a02fa36cf8a948
4
- data.tar.gz: 5cf855bce93ee306d909091109db3947c279ab284a00e96662b748b17fdb9a2c
3
+ metadata.gz: aefae6179b039a391256431f1581b0a57d28abf2a3c4edb33f9541368f30e3b8
4
+ data.tar.gz: 4e8d46b611a4874dd2f3f5399ab24a08fdcf85c5434cb04b194ef8bb45fa0bb3
5
5
  SHA512:
6
- metadata.gz: 6e272d644dd254dffb34be9997ce334fbd5ce76894c9315933cc8a0ac766c212eeba164c7deffdc93e87ef34e7bc9ae889ebcb249b5b3d99155cc5af6a1cc270
7
- data.tar.gz: d5867fa6b7f3e3279db592afada65c3bb85d801a17f604e56c7c660d871e33edc5f0afe7ef3703bfbbaa95074a7223df8d8aca954531e9066da36793decfb943
6
+ metadata.gz: f69e5c6708976f4e2448c5820584039685b4c6e61b2cc6162fb68759fb3f2e72e670a399eea0927f7fe16f3ebe56ea06d9c6a02a19d10394b962c06c33e596ce
7
+ data.tar.gz: 90dfb275ad24a7d88405c16c772227f8367f1d1c619c2bd0c7f129f711eb2cf431a338729d900c8b3146208d86148a2d9af28ed08b825eb5249a28ca5b1aea7f
@@ -1,19 +1 @@
1
- //= require jquery
2
- //= require jquery_ujs
3
- //= require popper
4
- //= require bootstrap
5
- //= require datatables/jquery.dataTables
6
- //= require datatables/dataTables.bootstrap4
7
- //= require datatables/extensions/Responsive/dataTables.responsive
8
- //= require datatables/extensions/Responsive/responsive.bootstrap4
9
- //= require datatables/extensions/Select/dataTables.select
10
- //= require nprogress
11
- //= require nprogress-turbolinks
12
- //= require nprogress-ajax
13
-
14
1
  //= require_tree ./chaltron
15
-
16
-
17
- NProgress.configure({
18
- showSpinner: false,
19
- });
@@ -0,0 +1,62 @@
1
+ // Using UMD pattern from
2
+ // https://github.com/umdjs/umd#regular-module
3
+ // `returnExports.js` version
4
+ (function (root, factory) {
5
+ if (typeof define === 'function' && define.amd) {
6
+ // AMD. Register as an anonymous module.
7
+ define('Chaltron', function(){ return factory(root);});
8
+ } else if (typeof module === 'object' && module.exports) {
9
+ // Node. Does not work with strict CommonJS, but
10
+ // only CommonJS-like environments that support module.exports,
11
+ // like Node.
12
+ module.exports = factory(root);
13
+ } else {
14
+ // Browser globals (root is window)
15
+ root.Chaltron = factory(root);
16
+ }
17
+ }(this, function(global) {
18
+ 'use strict';
19
+ // Use previously defined object if exists in current scope
20
+ var Chaltron = global && global.Chaltron || {};
21
+
22
+ // Check if value is different than undefined and null;
23
+ var isSet = function(value) {
24
+ return typeof(value) !== 'undefined' && value !== null;
25
+ };
26
+
27
+ var DEFAULT_OPTIONS = {
28
+ defaultLocale: 'en',
29
+ locale: 'en'
30
+ };
31
+ var key;
32
+ for (key in DEFAULT_OPTIONS) if (!isSet(Chaltron[key])) {
33
+ Chaltron[key] = DEFAULT_OPTIONS[key];
34
+ }
35
+
36
+ // Load locales files
37
+ Chaltron.locales = {}
38
+ <% Dir.glob(File.expand_path('../locales/*.json', __FILE__)) do |file| %>
39
+ Chaltron.locales["<%= File.basename(file, '.json') %>"] = <%= File.read(file) %>
40
+ <% end %>
41
+
42
+ // Return current locale. If no locale has been set, then
43
+ // the current locale will be the default locale.
44
+ Chaltron.currentLocale = function() {
45
+ return this.locale || this.defaultLocale;
46
+ };
47
+
48
+ Chaltron.missingTranslation = function(scope, locale) {
49
+ return 'missing translation ' + scope + ' for ' + locale;
50
+ };
51
+
52
+ Chaltron.translate = function(scope, locale) {
53
+ locale = locale || Chaltron.currentLocale();
54
+ if (!isSet(Chaltron.locales[locale]) || !isSet(Chaltron.locales[locale][scope])) {
55
+ return Chaltron.missingTranslation(scope, locale);
56
+ }
57
+ return Chaltron.locales[locale][scope];
58
+ };
59
+
60
+ // Just return a value to define the module export.
61
+ return Chaltron;
62
+ }));
@@ -0,0 +1,69 @@
1
+ document.addEventListener('turbolinks:load', function(){
2
+ var defaultOptions = {
3
+ destroy: true,
4
+ autoWidth: false,
5
+ responsive: true,
6
+ stateSave: true,
7
+ language: Chaltron.translate('datatables')
8
+ };
9
+
10
+ // generic datatable
11
+ var container = $('table.datatable');
12
+ if (container.length > 0) {
13
+ var table = container.DataTable(defaultOptions);
14
+ document.addEventListener('turbolinks:before-cache', function() {
15
+ table.destroy();
16
+ });
17
+ }
18
+
19
+ // users
20
+ container = $('table#users');
21
+ if (container.length > 0) {
22
+ var user_table = container.DataTable(defaultOptions);
23
+ document.addEventListener('turbolinks:before-cache', function() {
24
+ user_table.destroy();
25
+ });
26
+ }
27
+
28
+ // logs
29
+ container = $('table#logs');
30
+ if (container.length > 0) {
31
+ var log_table = container.DataTable($.extend({}, defaultOptions, {
32
+ processing: true,
33
+ serverSide: true,
34
+ ajax: container.data('source'),
35
+ // default sorting: date (2nd column) desc
36
+ order: [[1,'desc']],
37
+ columns: [
38
+ { data: 'severity', searchable: false },
39
+ { data: 'date', searchable: false },
40
+ { data: 'message' },
41
+ { data: 'category', searchable: false },
42
+ ],
43
+ columnDefs: [
44
+ { orderSequence: ['desc', 'asc'], targets: [ 1 ] },
45
+ { className: 'text-center', 'targets': [ 0 ] }
46
+ ]
47
+ }));
48
+ document.addEventListener('turbolinks:before-cache', function() {
49
+ log_table.destroy();
50
+ });
51
+ }
52
+
53
+ // ldap_create
54
+ container = $('table#ldap_create');
55
+ if (container.length > 0) {
56
+ var ldap_create_table = container.DataTable($.extend({}, defaultOptions, {
57
+ paging: false,
58
+ // default sorting: uid (2nd column) asc
59
+ order: [[1,'asc']],
60
+ columnDefs: [
61
+ { orderable: false, className: 'select-checkbox', targets: 0 }
62
+ ]
63
+ }));
64
+ document.addEventListener('turbolinks:before-cache', function() {
65
+ ldap_create_table.destroy();
66
+ });
67
+ }
68
+
69
+ });
@@ -0,0 +1,14 @@
1
+ document.addEventListener('turbolinks:load', function(){
2
+
3
+ // flash messages
4
+ var flash = $('.flash-container div.alert');
5
+ if (flash.length > 0) {
6
+ flash.click(function(){
7
+ $(this).fadeOut();
8
+ });
9
+ setTimeout(function(){
10
+ flash.fadeOut();
11
+ }, 5000);
12
+ }
13
+
14
+ });
@@ -0,0 +1,44 @@
1
+ $(document).on('turbolinks:load', function() {
2
+ container = $('table#ldap_create');
3
+ if (container.length > 0) {
4
+
5
+ var toggleButton = function() {
6
+ var any = $('input.entry' + ':checkbox')
7
+ .filter(function() { return this.checked; })
8
+ .length > 0;
9
+ if (any) {
10
+ $('#ldap_create_button').prop('disabled', false);
11
+ } else {
12
+ $('#ldap_create_button').prop('disabled', true);
13
+ }
14
+ };
15
+ // checkboxes
16
+ $('input.entry' + ':checkbox:disabled').prop('indeterminate', true);
17
+ $('input.entry' + ':checkbox').off().on('click', function() {
18
+ toggleButton();
19
+ });
20
+ $('#entry-check-all').off().on('click', function() {
21
+ $('input.entry' + ':checkbox:enabled').prop('checked', this.checked);
22
+ toggleButton();
23
+ });
24
+
25
+ $('form#ldap_create').on('submit', function(event) {
26
+ var selectedEntry = $('input.entry' + ':checkbox:checked')
27
+ .map(function() { return $(this).attr('data-entry'); })
28
+ .get();
29
+ if(selectedEntry.lenght == 0) {
30
+ // should nevere be here!!
31
+ event.preventDefault();
32
+ } else {
33
+ $.each(selectedEntry, function(index, entry){
34
+ $('<input/>', {
35
+ name: 'uids[]',
36
+ type: 'hidden',
37
+ multiple: 'multiple',
38
+ value: entry
39
+ }).appendTo('form#ldap_create');
40
+ });
41
+ }
42
+ });
43
+ }
44
+ });
@@ -0,0 +1,25 @@
1
+ {
2
+ "datatables": {
3
+ "sEmptyTable": "No data available in table",
4
+ "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
5
+ "sInfoEmpty": "Showing 0 to 0 of 0 entries",
6
+ "sInfoFiltered": "(filtered from _MAX_ total entries)",
7
+ "sInfoPostFix": "",
8
+ "sInfoThousands": ",",
9
+ "sLengthMenu": "Show _MENU_ entries",
10
+ "sLoadingRecords": "Loading...",
11
+ "sProcessing": "Processing...",
12
+ "sSearch": "Search:",
13
+ "sZeroRecords": "No matching records found",
14
+ "oPaginate": {
15
+ "sFirst": "First",
16
+ "sLast": "Last",
17
+ "sNext": "Next",
18
+ "sPrevious": "Previous"
19
+ },
20
+ "oAria": {
21
+ "sSortAscending": ": activate to sort column ascending",
22
+ "sSortDescending": ": activate to sort column descending"
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "datatables": {
3
+ "sEmptyTable": "Nessun dato presente nella tabella",
4
+ "sInfo": "Vista da _START_ a _END_ di _TOTAL_ elementi",
5
+ "sInfoEmpty": "Vista da 0 a 0 di 0 elementi",
6
+ "sInfoFiltered": "(filtrati da _MAX_ elementi totali)",
7
+ "sInfoPostFix": "",
8
+ "sInfoThousands": ".",
9
+ "sLengthMenu": "Visualizza _MENU_ elementi",
10
+ "sLoadingRecords": "Caricamento...",
11
+ "sProcessing": "Elaborazione...",
12
+ "sSearch": "Cerca:",
13
+ "sZeroRecords": "La ricerca non ha portato alcun risultato.",
14
+ "oPaginate": {
15
+ "sFirst": "Inizio",
16
+ "sPrevious": "Precedente",
17
+ "sNext": "Successivo",
18
+ "sLast": "Fine"
19
+ },
20
+ "oAria": {
21
+ "sSortAscending": ": attiva per ordinare la colonna in ordine crescente",
22
+ "sSortDescending": ": attiva per ordinare la colonna in ordine decrescente"
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,86 @@
1
+ function NavbarBuilder() {
2
+
3
+ function renderDropdownMenu(item){
4
+ var i, ref;
5
+ ref = $(item).find('ul li a');
6
+ for(i = 0; i < ref.length; i++) {
7
+ $(ref[i]).addClass('dropdown-item').removeClass('nav-link');
8
+ }
9
+ ref = $(item).find('ul');
10
+ for(i = 0; i < ref.length; i++) {
11
+ renderDropdownLinks(ref[i]);
12
+ }
13
+ }
14
+
15
+ function renderDropdownLinks(item) {
16
+ var links = $(item).find('li a');
17
+ klass = 'dropdown-menu';
18
+ if($(item).parent().hasClass('dropdown-menu-right')) {
19
+ klass += ' dropdown-menu-right';
20
+ }
21
+ var div = $('<div></div>').addClass(klass).attr('aria-labelledby', 'navbarDropdown').append(links);
22
+ $(item).replaceWith(div);
23
+ }
24
+
25
+ function prependClass(item, klass) {
26
+ if($(item).attr('class') ) {
27
+ klass += ' ' + $(item).attr('class');
28
+ }
29
+ $(item).addClass(klass);
30
+ if($(item).hasClass('justify-content-end')) {
31
+ $(item).removeClass('mr-auto');
32
+ }
33
+ }
34
+
35
+ function renderIconLink(item) {
36
+ if($(item).attr('icon') ) {
37
+ $(item).html("<i class=\"fa fa-" + $(item).attr('icon') + "\"></i>&nbsp;" + $(item).text());
38
+ }
39
+ }
40
+
41
+ return {
42
+ create: function () {
43
+ // backup
44
+ $('#navigation').data('navbar', $('#navigation').html());
45
+
46
+ var i, ref;
47
+ ref = $('#navigation ul');
48
+ for(i = 0; i < ref.length; i++) {
49
+ prependClass(ref[i], 'navbar-nav mr-auto');
50
+ }
51
+ $('#navigation ul li').addClass('nav-item');
52
+ $('#navigation ul li a').addClass('nav-link');
53
+ $('#navigation ul li ul').parent().addClass('dropdown');
54
+ $('#navigation ul li.dropdown').children('a').addClass('dropdown-toggle').attr(
55
+ {id: 'navbarDropdown', role: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', 'data-toggle': 'dropdown'}
56
+ );
57
+ ref = $('#navigation ul li.dropdown');
58
+ for(i = 0; i < ref.length; i++) {
59
+ renderDropdownMenu(ref[i]);
60
+ }
61
+ ref = $('#navigation ul li a');
62
+ for(i = 0; i < ref.length; i++) {
63
+ renderIconLink(ref[i]);
64
+ }
65
+ },
66
+ destroy: function () {
67
+ // restore
68
+ $('#navigation').html($('#navigation').data('navbar'));
69
+ }
70
+ };
71
+ }
72
+
73
+ document.addEventListener('turbolinks:load', function(){
74
+ var navbar = new NavbarBuilder();
75
+ navbar.create();
76
+ }, {once: true});
77
+
78
+ document.addEventListener('turbolinks:render', function(){
79
+ var navbar = new NavbarBuilder();
80
+ navbar.create();
81
+ });
82
+
83
+ document.addEventListener('turbolinks:before-render', function(){
84
+ var navbar = new NavbarBuilder();
85
+ navbar.destroy();
86
+ });
@@ -1,29 +1,2 @@
1
- // Bootstrap
2
- @import 'bootstrap';
3
-
4
- // font-awesome
5
- @import 'font-awesome-sprockets';
6
- @import 'font-awesome';
7
-
8
- // datatables
9
- @import 'datatables/dataTables.bootstrap4';
10
- @import 'datatables/extensions/Responsive/responsive.bootstrap4';
11
- @import 'datatables/extensions/Select/select.bootstrap4';
12
-
13
- // bootstrap_form
14
- @import 'rails_bootstrap_forms';
15
-
16
- // minor fix
17
- .dataTables_wrapper .dataTables_filter input {
18
- margin-left: 0.5em;
19
- }
20
-
21
- // nprogress
22
- @import 'nprogress';
23
- @import 'nprogress-bootstrap';
24
-
25
- // Core CSS
26
1
  @import 'chaltron/layout';
27
-
28
- // logs
29
2
  @import 'chaltron/logs';
@@ -18,4 +18,13 @@ module Chaltron::LdapHelper
18
18
  end
19
19
  end
20
20
 
21
+ def custom_checkbox(options)
22
+ id = options.delete(:id)
23
+ klass = options.delete(:class)
24
+ content_tag :div, class: 'custom-control custom-checkbox' do
25
+ check_box_tag('checkbox', nil, nil, options.merge(id: id, class: "custom-control-input d-none #{klass}")) +
26
+ label_tag(id, '', class: 'custom-control-label d-block', for: id)
27
+ end
28
+ end
29
+
21
30
  end
@@ -1,5 +1,7 @@
1
1
  <tr>
2
- <td></td>
2
+ <td>
3
+ <%= custom_checkbox(id: "checkbox-#{entry.username}", data: {entry: entry.username}, class: 'entry') %>
4
+ </td>
3
5
  <td class='username'><%= entry.username %></td>
4
6
  <td class='fullname'><%= display_entry_name(entry) %></td>
5
7
  <td class='email'><%= display_entry_email(entry) %></td>
@@ -12,7 +12,9 @@
12
12
  <%= content_tag 'table', id: 'ldap_create', class: 'table table-striped table-sm' do %>
13
13
  <thead>
14
14
  <tr>
15
- <th></th>
15
+ <th class='checkbox'>
16
+ <%= custom_checkbox(id: 'entry-check-all', class: 'entry') %>
17
+ </th>
16
18
  <th class='username'>
17
19
  <%= User.human_attribute_name(:username) %>
18
20
  </th>
@@ -39,7 +41,9 @@
39
41
  <div class='form-group row'>
40
42
  <div class='col-sm-2'></div>
41
43
  <div class='col-sm-10'>
42
- <%= f.submit t('.submit_text'), class: 'btn btn-primary' %>
44
+ <%= f.submit t('.submit_text'), id: 'ldap_create_button',
45
+ class: 'btn btn-primary',
46
+ disabled: true %>
43
47
  <%= back_link class: 'btn btn-default pull-right',
44
48
  text: t('chaltron.common.cancel'), icon: 'times' %>
45
49
  </div>
@@ -1,256 +1,260 @@
1
- # Use this hook to configure devise mailer, warden hooks and so forth.
2
- # Many of these configuration options can be set straight in your model.
3
- Devise.setup do |config|
4
- # The secret key used by Devise. Devise uses this key to generate
5
- # random tokens. Changing this key will render invalid all existing
6
- # confirmation, reset password and unlock tokens in the database.
7
- # config.secret_key = 'b329892371e2344d4ac2ca83059d9e4edee312765f952accfd5794570204e34d83bcdaf6fdcb9aa707d70a707f04695d6a88cf00693852533e913c26b658b455'
8
-
9
- # ==> Mailer Configuration
10
- # Configure the e-mail address which will be shown in Devise::Mailer,
11
- # note that it will be overwritten if you use your own mailer class
12
- # with default "from" parameter.
13
- config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
14
-
15
- # Configure the class responsible to send e-mails.
16
- # config.mailer = 'Devise::Mailer'
17
-
18
- # ==> ORM configuration
19
- # Load and configure the ORM. Supports :active_record (default) and
20
- # :mongoid (bson_ext recommended) by default. Other ORMs may be
21
- # available as additional gems.
22
- require 'devise/orm/active_record'
23
-
24
- # ==> Configuration for any authentication mechanism
25
- # Configure which keys are used when authenticating a user. The default is
26
- # just :email. You can configure it to use [:username, :subdomain], so for
27
- # authenticating a user, both parameters are required. Remember that those
28
- # parameters are used only when authenticating and not when retrieving from
29
- # session. If you need permissions, you should implement that in a before filter.
30
- # You can also supply a hash where the value is a boolean determining whether
31
- # or not authentication should be aborted when the value is not present.
32
- config.authentication_keys = [:login]
33
-
34
- # Configure parameters from the request object used for authentication. Each entry
35
- # given should be a request method and it will automatically be passed to the
36
- # find_for_authentication method and considered in your model lookup. For instance,
37
- # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
38
- # The same considerations mentioned for authentication_keys also apply to request_keys.
39
- # config.request_keys = []
40
-
41
- # Configure which authentication keys should be case-insensitive.
42
- # These keys will be downcased upon creating or modifying a user and when used
43
- # to authenticate or find a user. Default is :email.
44
- config.case_insensitive_keys = [:username, :email]
45
-
46
- # Configure which authentication keys should have whitespace stripped.
47
- # These keys will have whitespace before and after removed upon creating or
48
- # modifying a user and when used to authenticate or find a user. Default is :email.
49
- config.strip_whitespace_keys = [:username, :email]
50
-
51
- # Tell if authentication through request.params is enabled. True by default.
52
- # It can be set to an array that will enable params authentication only for the
53
- # given strategies, for example, `config.params_authenticatable = [:database]` will
54
- # enable it only for database (email + password) authentication.
55
- # config.params_authenticatable = true
56
-
57
- # Tell if authentication through HTTP Auth is enabled. False by default.
58
- # It can be set to an array that will enable http authentication only for the
59
- # given strategies, for example, `config.http_authenticatable = [:database]` will
60
- # enable it only for database authentication. The supported strategies are:
61
- # :database = Support basic authentication with authentication key + password
62
- # config.http_authenticatable = false
63
-
64
- # If http headers should be returned for AJAX requests. True by default.
65
- # config.http_authenticatable_on_xhr = true
66
-
67
- # The realm used in Http Basic Authentication. 'Application' by default.
68
- # config.http_authentication_realm = 'Application'
69
-
70
- # It will change confirmation, password recovery and other workflows
71
- # to behave the same regardless if the e-mail provided was right or wrong.
72
- # Does not affect registerable.
73
- # config.paranoid = true
74
-
75
- # By default Devise will store the user in session. You can skip storage for
76
- # particular strategies by setting this option.
77
- # Notice that if you are skipping storage for all authentication paths, you
78
- # may want to disable generating routes to Devise's sessions controller by
79
- # passing skip: :sessions to `devise_for` in your config/routes.rb
80
- config.skip_session_storage = [:http_auth]
81
-
82
- # By default, Devise cleans up the CSRF token on authentication to
83
- # avoid CSRF token fixation attacks. This means that, when using AJAX
84
- # requests for sign in and sign up, you need to get a new CSRF token
85
- # from the server. You can disable this option at your own risk.
86
- # config.clean_up_csrf_token_on_authentication = true
87
-
88
- # ==> Configuration for :database_authenticatable
89
- # For bcrypt, this is the cost for hashing the password and defaults to 10. If
90
- # using other encryptors, it sets how many times you want the password re-encrypted.
91
- #
92
- # Limiting the stretches to just one in testing will increase the performance of
93
- # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
94
- # a value less than 10 in other environments. Note that, for bcrypt (the default
95
- # encryptor), the cost increases exponentially with the number of stretches (e.g.
96
- # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
97
- config.stretches = Rails.env.test? ? 1 : 10
98
-
99
- # Setup a pepper to generate the encrypted password.
100
- # config.pepper = '2b12b15c7b15b7205f776f689afe0892252ab7273f8be6e46c0bd98b96790f1a930f0587db5a60e768ba79370513cae7c6b11e4babab1a0adabdd9f424f57291'
101
-
102
- # ==> Configuration for :confirmable
103
- # A period that the user is allowed to access the website even without
104
- # confirming their account. For instance, if set to 2.days, the user will be
105
- # able to access the website for two days without confirming their account,
106
- # access will be blocked just in the third day. Default is 0.days, meaning
107
- # the user cannot access the website without confirming their account.
108
- # config.allow_unconfirmed_access_for = 2.days
109
-
110
- # A period that the user is allowed to confirm their account before their
111
- # token becomes invalid. For example, if set to 3.days, the user can confirm
112
- # their account within 3 days after the mail was sent, but on the fourth day
113
- # their account can't be confirmed with the token any more.
114
- # Default is nil, meaning there is no restriction on how long a user can take
115
- # before confirming their account.
116
- # config.confirm_within = 3.days
117
-
118
- # If true, requires any email changes to be confirmed (exactly the same way as
119
- # initial account confirmation) to be applied. Requires additional unconfirmed_email
120
- # db field (see migrations). Until confirmed, new email is stored in
121
- # unconfirmed_email column, and copied to email column on successful confirmation.
122
- config.reconfirmable = true
123
-
124
- # Defines which key will be used when confirming an account
125
- # config.confirmation_keys = [ :email ]
126
-
127
- # ==> Configuration for :rememberable
128
- # The time the user will be remembered without asking for credentials again.
129
- # config.remember_for = 2.weeks
130
-
131
- # If true, extends the user's remember period when remembered via cookie.
132
- # config.extend_remember_period = false
133
-
134
- # Options to be passed to the created cookie. For instance, you can set
135
- # secure: true in order to force SSL only cookies.
136
- # config.rememberable_options = {}
137
-
138
- # ==> Configuration for :validatable
139
- # Range for password length.
140
- config.password_length = 8..128
141
-
142
- # Email regex used to validate email formats. It simply asserts that
143
- # one (and only one) @ exists in the given string. This is mainly
144
- # to give user feedback and not to assert the e-mail validity.
145
- config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
146
-
147
- # ==> Configuration for :timeoutable
148
- # The time you want to timeout the user session without activity. After this
149
- # time the user will be asked for credentials again. Default is 30 minutes.
150
- # config.timeout_in = 30.minutes
151
-
152
- # If true, expires auth token on session timeout.
153
- # config.expire_auth_token_on_timeout = false
154
-
155
- # ==> Configuration for :lockable
156
- # Defines which strategy will be used to lock an account.
157
- # :failed_attempts = Locks an account after a number of failed attempts to sign in.
158
- # :none = No lock strategy. You should handle locking by yourself.
159
- # config.lock_strategy = :failed_attempts
160
-
161
- # Defines which key will be used when locking and unlocking an account
162
- # config.unlock_keys = [ :email ]
163
-
164
- # Defines which strategy will be used to unlock an account.
165
- # :email = Sends an unlock link to the user email
166
- # :time = Re-enables login after a certain amount of time (see :unlock_in below)
167
- # :both = Enables both strategies
168
- # :none = No unlock strategy. You should handle unlocking by yourself.
169
- # config.unlock_strategy = :both
170
-
171
- # Number of authentication tries before locking an account if lock_strategy
172
- # is failed attempts.
173
- # config.maximum_attempts = 20
174
-
175
- # Time interval to unlock the account if :time is enabled as unlock_strategy.
176
- # config.unlock_in = 1.hour
177
-
178
- # Warn on the last attempt before the account is locked.
179
- # config.last_attempt_warning = false
180
-
181
- # ==> Configuration for :recoverable
182
- #
183
- # Defines which key will be used when recovering the password for an account
184
- # config.reset_password_keys = [ :email ]
185
-
186
- # Time interval you can reset your password with a reset password key.
187
- # Don't put a too small interval or your users won't have the time to
188
- # change their passwords.
189
- config.reset_password_within = 6.hours
190
-
191
- # ==> Configuration for :encryptable
192
- # Allow you to use another encryption algorithm besides bcrypt (default). You can use
193
- # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
194
- # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
195
- # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
196
- # REST_AUTH_SITE_KEY to pepper).
197
- #
198
- # Require the `devise-encryptable` gem when using anything other than bcrypt
199
- # config.encryptor = :sha512
200
-
201
- # ==> Scopes configuration
202
- # Turn scoped views on. Before rendering "sessions/new", it will first check for
203
- # "users/sessions/new". It's turned off by default because it's slower if you
204
- # are using only default views.
205
- # config.scoped_views = false
206
-
207
- # Configure the default scope given to Warden. By default it's the first
208
- # devise role declared in your routes (usually :user).
209
- # config.default_scope = :user
210
-
211
- # Set this configuration to false if you want /users/sign_out to sign out
212
- # only the current scope. By default, Devise signs out all scopes.
213
- # config.sign_out_all_scopes = true
214
-
215
- # ==> Navigation configuration
216
- # Lists the formats that should be treated as navigational. Formats like
217
- # :html, should redirect to the sign in page when the user does not have
218
- # access, but formats like :xml or :json, should return 401.
219
- #
220
- # If you have any extra navigational formats, like :iphone or :mobile, you
221
- # should add them to the navigational formats lists.
222
- #
223
- # The "*/*" below is required to match Internet Explorer requests.
224
- # config.navigational_formats = ['*/*', :html]
225
-
226
- # The default HTTP method used to sign out a resource. Default is :delete.
227
- config.sign_out_via = :delete
228
-
229
- # ==> OmniAuth
230
- # Add a new OmniAuth provider. Check the wiki for more information on setting
231
- # up on your models and hooks.
232
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
233
-
234
- # ==> Warden configuration
235
- # If you want to use other strategies, that are not supported by Devise, or
236
- # change the failure app, you can configure them inside the config.warden block.
237
- #
238
- # config.warden do |manager|
239
- # manager.intercept_401 = false
240
- # manager.default_strategies(scope: :user).unshift :some_external_strategy
241
- # end
242
-
243
- # ==> Mountable engine configurations
244
- # When using Devise inside an engine, let's call it `MyEngine`, and this engine
245
- # is mountable, there are some extra configurations to be taken into account.
246
- # The following options are available, assuming the engine is mounted as:
247
- #
248
- # mount MyEngine, at: '/my_engine'
249
- #
250
- # The router that invoked `devise_for`, in the example above, would be:
251
- # config.router_name = :my_engine
252
- #
253
- # When using omniauth, Devise cannot automatically set Omniauth path,
254
- # so you need to do it manually. For the users scope, it would be:
255
- # config.omniauth_path_prefix = '/my_engine/users/auth'
1
+ if defined?(Devise)
2
+ require 'omniauth-ldap'
3
+
4
+ # Use this hook to configure devise mailer, warden hooks and so forth.
5
+ # Many of these configuration options can be set straight in your model.
6
+ Devise.setup do |config|
7
+ # The secret key used by Devise. Devise uses this key to generate
8
+ # random tokens. Changing this key will render invalid all existing
9
+ # confirmation, reset password and unlock tokens in the database.
10
+ # config.secret_key = 'b329892371e2344d4ac2ca83059d9e4edee312765f952accfd5794570204e34d83bcdaf6fdcb9aa707d70a707f04695d6a88cf00693852533e913c26b658b455'
11
+
12
+ # ==> Mailer Configuration
13
+ # Configure the e-mail address which will be shown in Devise::Mailer,
14
+ # note that it will be overwritten if you use your own mailer class
15
+ # with default "from" parameter.
16
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
17
+
18
+ # Configure the class responsible to send e-mails.
19
+ # config.mailer = 'Devise::Mailer'
20
+
21
+ # ==> ORM configuration
22
+ # Load and configure the ORM. Supports :active_record (default) and
23
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
24
+ # available as additional gems.
25
+ require 'devise/orm/active_record'
26
+
27
+ # ==> Configuration for any authentication mechanism
28
+ # Configure which keys are used when authenticating a user. The default is
29
+ # just :email. You can configure it to use [:username, :subdomain], so for
30
+ # authenticating a user, both parameters are required. Remember that those
31
+ # parameters are used only when authenticating and not when retrieving from
32
+ # session. If you need permissions, you should implement that in a before filter.
33
+ # You can also supply a hash where the value is a boolean determining whether
34
+ # or not authentication should be aborted when the value is not present.
35
+ config.authentication_keys = [:login]
36
+
37
+ # Configure parameters from the request object used for authentication. Each entry
38
+ # given should be a request method and it will automatically be passed to the
39
+ # find_for_authentication method and considered in your model lookup. For instance,
40
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
41
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
42
+ # config.request_keys = []
43
+
44
+ # Configure which authentication keys should be case-insensitive.
45
+ # These keys will be downcased upon creating or modifying a user and when used
46
+ # to authenticate or find a user. Default is :email.
47
+ config.case_insensitive_keys = [:username, :email]
48
+
49
+ # Configure which authentication keys should have whitespace stripped.
50
+ # These keys will have whitespace before and after removed upon creating or
51
+ # modifying a user and when used to authenticate or find a user. Default is :email.
52
+ config.strip_whitespace_keys = [:username, :email]
53
+
54
+ # Tell if authentication through request.params is enabled. True by default.
55
+ # It can be set to an array that will enable params authentication only for the
56
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
57
+ # enable it only for database (email + password) authentication.
58
+ # config.params_authenticatable = true
59
+
60
+ # Tell if authentication through HTTP Auth is enabled. False by default.
61
+ # It can be set to an array that will enable http authentication only for the
62
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
63
+ # enable it only for database authentication. The supported strategies are:
64
+ # :database = Support basic authentication with authentication key + password
65
+ # config.http_authenticatable = false
66
+
67
+ # If http headers should be returned for AJAX requests. True by default.
68
+ # config.http_authenticatable_on_xhr = true
69
+
70
+ # The realm used in Http Basic Authentication. 'Application' by default.
71
+ # config.http_authentication_realm = 'Application'
72
+
73
+ # It will change confirmation, password recovery and other workflows
74
+ # to behave the same regardless if the e-mail provided was right or wrong.
75
+ # Does not affect registerable.
76
+ # config.paranoid = true
77
+
78
+ # By default Devise will store the user in session. You can skip storage for
79
+ # particular strategies by setting this option.
80
+ # Notice that if you are skipping storage for all authentication paths, you
81
+ # may want to disable generating routes to Devise's sessions controller by
82
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
83
+ config.skip_session_storage = [:http_auth]
84
+
85
+ # By default, Devise cleans up the CSRF token on authentication to
86
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
87
+ # requests for sign in and sign up, you need to get a new CSRF token
88
+ # from the server. You can disable this option at your own risk.
89
+ # config.clean_up_csrf_token_on_authentication = true
90
+
91
+ # ==> Configuration for :database_authenticatable
92
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
93
+ # using other encryptors, it sets how many times you want the password re-encrypted.
94
+ #
95
+ # Limiting the stretches to just one in testing will increase the performance of
96
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
97
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
98
+ # encryptor), the cost increases exponentially with the number of stretches (e.g.
99
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
100
+ config.stretches = Rails.env.test? ? 1 : 10
101
+
102
+ # Setup a pepper to generate the encrypted password.
103
+ # config.pepper = '2b12b15c7b15b7205f776f689afe0892252ab7273f8be6e46c0bd98b96790f1a930f0587db5a60e768ba79370513cae7c6b11e4babab1a0adabdd9f424f57291'
104
+
105
+ # ==> Configuration for :confirmable
106
+ # A period that the user is allowed to access the website even without
107
+ # confirming their account. For instance, if set to 2.days, the user will be
108
+ # able to access the website for two days without confirming their account,
109
+ # access will be blocked just in the third day. Default is 0.days, meaning
110
+ # the user cannot access the website without confirming their account.
111
+ # config.allow_unconfirmed_access_for = 2.days
112
+
113
+ # A period that the user is allowed to confirm their account before their
114
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
115
+ # their account within 3 days after the mail was sent, but on the fourth day
116
+ # their account can't be confirmed with the token any more.
117
+ # Default is nil, meaning there is no restriction on how long a user can take
118
+ # before confirming their account.
119
+ # config.confirm_within = 3.days
120
+
121
+ # If true, requires any email changes to be confirmed (exactly the same way as
122
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
123
+ # db field (see migrations). Until confirmed, new email is stored in
124
+ # unconfirmed_email column, and copied to email column on successful confirmation.
125
+ config.reconfirmable = true
126
+
127
+ # Defines which key will be used when confirming an account
128
+ # config.confirmation_keys = [ :email ]
129
+
130
+ # ==> Configuration for :rememberable
131
+ # The time the user will be remembered without asking for credentials again.
132
+ # config.remember_for = 2.weeks
133
+
134
+ # If true, extends the user's remember period when remembered via cookie.
135
+ # config.extend_remember_period = false
136
+
137
+ # Options to be passed to the created cookie. For instance, you can set
138
+ # secure: true in order to force SSL only cookies.
139
+ # config.rememberable_options = {}
140
+
141
+ # ==> Configuration for :validatable
142
+ # Range for password length.
143
+ config.password_length = 8..128
144
+
145
+ # Email regex used to validate email formats. It simply asserts that
146
+ # one (and only one) @ exists in the given string. This is mainly
147
+ # to give user feedback and not to assert the e-mail validity.
148
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
149
+
150
+ # ==> Configuration for :timeoutable
151
+ # The time you want to timeout the user session without activity. After this
152
+ # time the user will be asked for credentials again. Default is 30 minutes.
153
+ # config.timeout_in = 30.minutes
154
+
155
+ # If true, expires auth token on session timeout.
156
+ # config.expire_auth_token_on_timeout = false
157
+
158
+ # ==> Configuration for :lockable
159
+ # Defines which strategy will be used to lock an account.
160
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
161
+ # :none = No lock strategy. You should handle locking by yourself.
162
+ # config.lock_strategy = :failed_attempts
163
+
164
+ # Defines which key will be used when locking and unlocking an account
165
+ # config.unlock_keys = [ :email ]
166
+
167
+ # Defines which strategy will be used to unlock an account.
168
+ # :email = Sends an unlock link to the user email
169
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
170
+ # :both = Enables both strategies
171
+ # :none = No unlock strategy. You should handle unlocking by yourself.
172
+ # config.unlock_strategy = :both
173
+
174
+ # Number of authentication tries before locking an account if lock_strategy
175
+ # is failed attempts.
176
+ # config.maximum_attempts = 20
177
+
178
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
179
+ # config.unlock_in = 1.hour
180
+
181
+ # Warn on the last attempt before the account is locked.
182
+ # config.last_attempt_warning = false
183
+
184
+ # ==> Configuration for :recoverable
185
+ #
186
+ # Defines which key will be used when recovering the password for an account
187
+ # config.reset_password_keys = [ :email ]
188
+
189
+ # Time interval you can reset your password with a reset password key.
190
+ # Don't put a too small interval or your users won't have the time to
191
+ # change their passwords.
192
+ config.reset_password_within = 6.hours
193
+
194
+ # ==> Configuration for :encryptable
195
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
196
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
197
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
198
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
199
+ # REST_AUTH_SITE_KEY to pepper).
200
+ #
201
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
202
+ # config.encryptor = :sha512
203
+
204
+ # ==> Scopes configuration
205
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
206
+ # "users/sessions/new". It's turned off by default because it's slower if you
207
+ # are using only default views.
208
+ # config.scoped_views = false
209
+
210
+ # Configure the default scope given to Warden. By default it's the first
211
+ # devise role declared in your routes (usually :user).
212
+ # config.default_scope = :user
213
+
214
+ # Set this configuration to false if you want /users/sign_out to sign out
215
+ # only the current scope. By default, Devise signs out all scopes.
216
+ # config.sign_out_all_scopes = true
217
+
218
+ # ==> Navigation configuration
219
+ # Lists the formats that should be treated as navigational. Formats like
220
+ # :html, should redirect to the sign in page when the user does not have
221
+ # access, but formats like :xml or :json, should return 401.
222
+ #
223
+ # If you have any extra navigational formats, like :iphone or :mobile, you
224
+ # should add them to the navigational formats lists.
225
+ #
226
+ # The "*/*" below is required to match Internet Explorer requests.
227
+ # config.navigational_formats = ['*/*', :html]
228
+
229
+ # The default HTTP method used to sign out a resource. Default is :delete.
230
+ config.sign_out_via = :delete
231
+
232
+ # ==> OmniAuth
233
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
234
+ # up on your models and hooks.
235
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
236
+
237
+ # ==> Warden configuration
238
+ # If you want to use other strategies, that are not supported by Devise, or
239
+ # change the failure app, you can configure them inside the config.warden block.
240
+ #
241
+ # config.warden do |manager|
242
+ # manager.intercept_401 = false
243
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
244
+ # end
245
+
246
+ # ==> Mountable engine configurations
247
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
248
+ # is mountable, there are some extra configurations to be taken into account.
249
+ # The following options are available, assuming the engine is mounted as:
250
+ #
251
+ # mount MyEngine, at: '/my_engine'
252
+ #
253
+ # The router that invoked `devise_for`, in the example above, would be:
254
+ # config.router_name = :my_engine
255
+ #
256
+ # When using omniauth, Devise cannot automatically set Omniauth path,
257
+ # so you need to do it manually. For the users scope, it would be:
258
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
259
+ end
256
260
  end