morpho 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/api/concerns/morpho/grape/http_responses.rb +41 -0
- data/app/api/concerns/morpho/grape/jwt_authentication.rb +77 -0
- data/app/api/concerns/morpho/grape/user_activation.rb +13 -0
- data/app/api/concerns/morpho/grape/user_password_reset.rb +13 -0
- data/app/api/concerns/morpho/grape/user_registration.rb +19 -0
- data/app/api/concerns/morpho/grape/user_unlock.rb +13 -0
- data/app/api/morpho/api.rb +24 -0
- data/app/api/morpho/entities/authentication_token.rb +8 -0
- data/app/api/morpho/entities/user.rb +7 -0
- data/app/api/morpho/entities/user_sign_in.rb +8 -0
- data/app/api/morpho/entities/user_sign_up.rb +9 -0
- data/app/api/morpho/resources/activations.rb +29 -0
- data/app/api/morpho/resources/passwords.rb +25 -0
- data/app/api/morpho/resources/tokens.rb +19 -0
- data/app/api/morpho/resources/unlocks.rb +29 -0
- data/app/api/morpho/resources/users.rb +19 -0
- data/app/assets/images/morpho/morpho.png +0 -0
- data/app/assets/images/morpho/morpho.svg +89 -0
- data/app/assets/stylesheets/morpho/application.css +74 -1
- data/app/controllers/morpho/activations_controller.rb +44 -0
- data/app/controllers/morpho/application_controller.rb +9 -0
- data/app/controllers/morpho/home_controller.rb +6 -0
- data/app/controllers/morpho/passwords_controller.rb +56 -0
- data/app/controllers/morpho/sessions_controller.rb +24 -0
- data/app/controllers/morpho/unlocks_controller.rb +44 -0
- data/app/controllers/morpho/users_controller.rb +25 -0
- data/app/mailers/morpho/application_mailer.rb +0 -1
- data/app/mailers/morpho/user_mailer.rb +31 -0
- data/app/models/morpho/authentication.rb +5 -0
- data/app/models/morpho/user.rb +60 -0
- data/app/views/layouts/morpho/application.html.erb +6 -4
- data/app/views/layouts/morpho/mailer.html.erb +13 -0
- data/app/views/layouts/morpho/mailer.text.erb +1 -0
- data/app/views/morpho/activations/new.html.erb +16 -0
- data/app/views/morpho/home/index.html.erb +4 -0
- data/app/views/morpho/passwords/edit.html.erb +18 -0
- data/app/views/morpho/passwords/new.html.erb +16 -0
- data/app/views/morpho/sessions/new.html.erb +23 -0
- data/app/views/morpho/unlocks/new.html.erb +16 -0
- data/app/views/morpho/user_mailer/activation_needed_email.html.erb +7 -0
- data/app/views/morpho/user_mailer/activation_needed_email.text.erb +7 -0
- data/app/views/morpho/user_mailer/activation_success_email.html.erb +7 -0
- data/app/views/morpho/user_mailer/activation_success_email.text.erb +7 -0
- data/app/views/morpho/user_mailer/reset_password_email.html.erb +7 -0
- data/app/views/morpho/user_mailer/reset_password_email.text.erb +7 -0
- data/app/views/morpho/user_mailer/unlock_token_email.html.erb +7 -0
- data/app/views/morpho/user_mailer/unlock_token_email.text.erb +7 -0
- data/app/views/morpho/users/new.html.erb +20 -0
- data/config/initializers/flash_rails_messages_skeleton.rb +22 -0
- data/config/initializers/simple_form.rb +182 -0
- data/config/initializers/sorcery.rb +513 -0
- data/config/locales/morpho.en.yml +93 -0
- data/config/routes.rb +25 -0
- data/db/migrate/20180919162009_sorcery_core.rb +13 -0
- data/db/migrate/20180919162055_sorcery_remember_me.rb +8 -0
- data/db/migrate/20180919162056_sorcery_reset_password.rb +10 -0
- data/db/migrate/20180919162057_sorcery_user_activation.rb +9 -0
- data/db/migrate/20180919162058_sorcery_brute_force_protection.rb +9 -0
- data/db/migrate/20180919162059_sorcery_activity_logging.rb +10 -0
- data/db/migrate/20180919162100_sorcery_external.rb +12 -0
- data/lib/generators/morpho/install/install_generator.rb +7 -0
- data/lib/generators/morpho/install/templates/config/initializers/morpho.rb +17 -0
- data/lib/generators/morpho/install/templates/public/favicon-16x16.png +0 -0
- data/lib/generators/morpho/install/templates/public/favicon-32x32.png +0 -0
- data/lib/generators/morpho/install/templates/public/favicon.ico +0 -0
- data/lib/morpho.rb +15 -2
- data/lib/morpho/configuration.rb +24 -0
- data/lib/morpho/configurations/api.rb +31 -0
- data/lib/morpho/configurations/auth.rb +11 -0
- data/lib/morpho/configurations/jwt.rb +17 -0
- data/lib/morpho/configurations/mailer.rb +23 -0
- data/lib/morpho/engine.rb +33 -0
- data/lib/morpho/loader.rb +11 -0
- data/lib/morpho/version.rb +1 -1
- data/lib/tasks/morpho_tasks.rake +1 -1
- data/lib/templates/erb/scaffold/_form.html.erb +15 -0
- metadata +223 -2
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="activation-form">
|
2
|
+
<%= simple_form_for :user, url: send_activation_path do |f| %>
|
3
|
+
<%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
|
4
|
+
|
5
|
+
<%= f.submit t('morpho.labels.activations.send_instructions'), class: 'button-primary u-full-width' %>
|
6
|
+
|
7
|
+
<ul class="unstyled">
|
8
|
+
<li>
|
9
|
+
<%= link_to t('morpho.labels.activations.sign_in'), sign_in_path %>
|
10
|
+
</li>
|
11
|
+
<li>
|
12
|
+
<%= link_to t('morpho.labels.activations.sign_up'), sign_up_path %>
|
13
|
+
</li>
|
14
|
+
</ul>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="sign-up-form">
|
2
|
+
<%= simple_form_for user, url: change_password_path(token: params[:token]), method: :put do |f| %>
|
3
|
+
<%= f.input :password, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
|
4
|
+
|
5
|
+
<%= f.input :password_confirmation, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
|
6
|
+
|
7
|
+
<%= f.submit t('morpho.labels.passwords.change_password'), class: 'button-primary u-full-width' %>
|
8
|
+
|
9
|
+
<ul class="unstyled">
|
10
|
+
<li>
|
11
|
+
<%= link_to t('morpho.labels.passwords.sign_in'), sign_in_path %>
|
12
|
+
</li>
|
13
|
+
<li>
|
14
|
+
<%= link_to t('morpho.labels.passwords.sign_up'), sign_up_path %>
|
15
|
+
</li>
|
16
|
+
</ul>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="reset-password-form">
|
2
|
+
<%= simple_form_for :user, url: send_reset_password_path do |f| %>
|
3
|
+
<%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
|
4
|
+
|
5
|
+
<%= f.submit t('morpho.labels.passwords.send_instructions'), class: 'button-primary u-full-width' %>
|
6
|
+
|
7
|
+
<ul class="unstyled">
|
8
|
+
<li>
|
9
|
+
<%= link_to t('morpho.labels.passwords.sign_in'), sign_in_path %>
|
10
|
+
</li>
|
11
|
+
<li>
|
12
|
+
<%= link_to t('morpho.labels.passwords.sign_up'), sign_up_path %>
|
13
|
+
</li>
|
14
|
+
</ul>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class="sign-in-form">
|
2
|
+
<%= simple_form_for :session, url: sign_in_path do |f| %>
|
3
|
+
<%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
|
4
|
+
|
5
|
+
<%= f.input :password, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
|
6
|
+
|
7
|
+
<%= f.input :remember_me, as: :boolean %>
|
8
|
+
|
9
|
+
<%= f.submit t('morpho.labels.sessions.sign_in'), class: 'button-primary u-full-width' %>
|
10
|
+
|
11
|
+
<ul class="unstyled">
|
12
|
+
<li>
|
13
|
+
<%= link_to t('morpho.labels.sessions.sign_up'), sign_up_path %>
|
14
|
+
</li>
|
15
|
+
<li>
|
16
|
+
<%= link_to t('morpho.labels.sessions.password_reset'), new_reset_password_path %>
|
17
|
+
</li>
|
18
|
+
<li>
|
19
|
+
<%= link_to t('morpho.labels.sessions.unlock'), new_unlock_path %>
|
20
|
+
</li>
|
21
|
+
</ul>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="unlock-form">
|
2
|
+
<%= simple_form_for :user, url: send_unlock_path do |f| %>
|
3
|
+
<%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
|
4
|
+
|
5
|
+
<%= f.submit t('morpho.labels.unlocks.send_instructions'), class: 'button-primary u-full-width' %>
|
6
|
+
|
7
|
+
<ul class="unstyled">
|
8
|
+
<li>
|
9
|
+
<%= link_to t('morpho.labels.unlocks.sign_in'), sign_in_path %>
|
10
|
+
</li>
|
11
|
+
<li>
|
12
|
+
<%= link_to t('morpho.labels.unlocks.sign_up'), sign_up_path %>
|
13
|
+
</li>
|
14
|
+
</ul>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>Welcome <%= @user.email %>,</p>
|
2
|
+
|
3
|
+
<p>You have successfully signed up, you're just a step behind to finish.</p>
|
4
|
+
|
5
|
+
<p>To verify your user email address and activate your user account, just follow this <a href=" <%= @url %>">link</a>.</p>
|
6
|
+
|
7
|
+
<p>Thanks for joining and have a great day!</p>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>Hello <%= @user.email %>,</p>
|
2
|
+
|
3
|
+
<p>Your account has been locked due to failed login attempts activity.</p>
|
4
|
+
|
5
|
+
<p>To unlock your account now, just follow this <a href=" <%= @url %>">link</a>. Anyway it will be automatically unlocked in an hour.</p>
|
6
|
+
|
7
|
+
<p>Have a great day!</p>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="sign-up-form">
|
2
|
+
<%= simple_form_for user, url: sign_up_path do |f| %>
|
3
|
+
<%= f.input :email, required: true, placeholder: 'johndoe@example.com', input_html: { class: 'u-full-width' } %>
|
4
|
+
|
5
|
+
<%= f.input :password, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
|
6
|
+
|
7
|
+
<%= f.input :password_confirmation, required: true, placeholder: '************', input_html: { class: 'u-full-width' } %>
|
8
|
+
|
9
|
+
<%= f.submit t('morpho.labels.users.sign_up'), class: 'button-primary u-full-width' %>
|
10
|
+
|
11
|
+
<ul class="unstyled">
|
12
|
+
<li>
|
13
|
+
<%= link_to t('morpho.labels.users.sign_in'), sign_in_path %>
|
14
|
+
</li>
|
15
|
+
<li>
|
16
|
+
<%= link_to t('morpho.labels.users.activation'), new_activation_path %>
|
17
|
+
</li>
|
18
|
+
</ul>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module FlashRailsMessages
|
2
|
+
class Base
|
3
|
+
def alert_element(type, message)
|
4
|
+
content_tag :div, class: alert_classes(type) do
|
5
|
+
message.html_safe
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def default_alert_class
|
10
|
+
'alert'
|
11
|
+
end
|
12
|
+
|
13
|
+
def alert_type_classes
|
14
|
+
{
|
15
|
+
success: 'alert-success',
|
16
|
+
notice: 'alert-info',
|
17
|
+
alert: 'alert-warning',
|
18
|
+
error: 'alert-error',
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Uncomment this and change the path if necessary to include your own
|
4
|
+
# components.
|
5
|
+
# See https://github.com/plataformatec/simple_form#custom-components to know
|
6
|
+
# more about custom components.
|
7
|
+
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
8
|
+
#
|
9
|
+
# Use this setup block to configure all options available in SimpleForm.
|
10
|
+
SimpleForm.setup do |config|
|
11
|
+
# Wrappers are used by the form builder to generate a
|
12
|
+
# complete input. You can remove any component from the
|
13
|
+
# wrapper, change the order or even add your own to the
|
14
|
+
# stack. The options given below are used to wrap the
|
15
|
+
# whole input.
|
16
|
+
config.wrappers :default, class: :input,
|
17
|
+
hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b|
|
18
|
+
## Extensions enabled by default
|
19
|
+
# Any of these extensions can be disabled for a
|
20
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
21
|
+
# You can make any of these extensions optional by
|
22
|
+
# renaming `b.use` to `b.optional`.
|
23
|
+
|
24
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
25
|
+
# and required attributes
|
26
|
+
b.use :html5
|
27
|
+
|
28
|
+
# Calculates placeholders automatically from I18n
|
29
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
30
|
+
b.use :placeholder
|
31
|
+
|
32
|
+
## Optional extensions
|
33
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
34
|
+
# to the input. If so, they will retrieve the values from the model
|
35
|
+
# if any exists. If you want to enable any of those
|
36
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
37
|
+
|
38
|
+
# Calculates maxlength from length validations for string inputs
|
39
|
+
# and/or database column lengths
|
40
|
+
b.optional :maxlength
|
41
|
+
|
42
|
+
# Calculate minlength from length validations for string inputs
|
43
|
+
b.optional :minlength
|
44
|
+
|
45
|
+
# Calculates pattern from format validations for string inputs
|
46
|
+
b.optional :pattern
|
47
|
+
|
48
|
+
# Calculates min and max from length validations for numeric inputs
|
49
|
+
b.optional :min_max
|
50
|
+
|
51
|
+
# Calculates readonly automatically from readonly attributes
|
52
|
+
b.optional :readonly
|
53
|
+
|
54
|
+
## Inputs
|
55
|
+
# b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid'
|
56
|
+
b.use :label_input
|
57
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
58
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
59
|
+
|
60
|
+
## full_messages_for
|
61
|
+
# If you want to display the full error message for the attribute, you can
|
62
|
+
# use the component :full_error, like:
|
63
|
+
#
|
64
|
+
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
65
|
+
end
|
66
|
+
|
67
|
+
# The default wrapper to be used by the FormBuilder.
|
68
|
+
config.default_wrapper = :default
|
69
|
+
|
70
|
+
# Define the way to render check boxes / radio buttons with labels.
|
71
|
+
# Defaults to :nested for bootstrap config.
|
72
|
+
# inline: input + label
|
73
|
+
# nested: label > input
|
74
|
+
config.boolean_style = :inline
|
75
|
+
|
76
|
+
# Default class for buttons
|
77
|
+
config.button_class = 'btn'
|
78
|
+
|
79
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
80
|
+
# :first lists the first message for each field.
|
81
|
+
# Use :to_sentence to list all errors for each field.
|
82
|
+
# config.error_method = :first
|
83
|
+
|
84
|
+
# Default tag used for error notification helper.
|
85
|
+
config.error_notification_tag = :div
|
86
|
+
|
87
|
+
# CSS class to add for error notification helper.
|
88
|
+
config.error_notification_class = 'error_notification'
|
89
|
+
|
90
|
+
# ID to add for error notification helper.
|
91
|
+
# config.error_notification_id = nil
|
92
|
+
|
93
|
+
# Series of attempts to detect a default label method for collection.
|
94
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
95
|
+
|
96
|
+
# Series of attempts to detect a default value method for collection.
|
97
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
98
|
+
|
99
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
100
|
+
# config.collection_wrapper_tag = nil
|
101
|
+
|
102
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
103
|
+
# config.collection_wrapper_class = nil
|
104
|
+
|
105
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
106
|
+
# defaulting to :span.
|
107
|
+
# config.item_wrapper_tag = :span
|
108
|
+
|
109
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
110
|
+
# config.item_wrapper_class = nil
|
111
|
+
|
112
|
+
# How the label text should be generated altogether with the required text.
|
113
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
114
|
+
|
115
|
+
# You can define the class to use on all labels. Default is nil.
|
116
|
+
# config.label_class = nil
|
117
|
+
|
118
|
+
# You can define the default class to be used on forms. Can be overriden
|
119
|
+
# with `html: { :class }`. Defaulting to none.
|
120
|
+
# config.default_form_class = nil
|
121
|
+
|
122
|
+
# You can define which elements should obtain additional classes
|
123
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
124
|
+
|
125
|
+
# Whether attributes are required by default (or not). Default is true.
|
126
|
+
# config.required_by_default = true
|
127
|
+
|
128
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
129
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
130
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
131
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
132
|
+
# change this configuration to true.
|
133
|
+
config.browser_validations = false
|
134
|
+
|
135
|
+
# Collection of methods to detect if a file type was given.
|
136
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ]
|
137
|
+
|
138
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
139
|
+
# to match as key, and the input type that will be used when the field name
|
140
|
+
# matches the regexp as value.
|
141
|
+
# config.input_mappings = { /count/ => :integer }
|
142
|
+
|
143
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
144
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
145
|
+
# config.wrapper_mappings = { string: :prepend }
|
146
|
+
|
147
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
148
|
+
# override default inputs.
|
149
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
150
|
+
|
151
|
+
# Default priority for time_zone inputs.
|
152
|
+
# config.time_zone_priority = nil
|
153
|
+
|
154
|
+
# Default priority for country inputs.
|
155
|
+
# config.country_priority = nil
|
156
|
+
|
157
|
+
# When false, do not use translations for labels.
|
158
|
+
# config.translate_labels = true
|
159
|
+
|
160
|
+
# Automatically discover new inputs in Rails' autoload path.
|
161
|
+
# config.inputs_discovery = true
|
162
|
+
|
163
|
+
# Cache SimpleForm inputs discovery
|
164
|
+
# config.cache_discovery = !Rails.env.development?
|
165
|
+
|
166
|
+
# Default class for inputs
|
167
|
+
# config.input_class = nil
|
168
|
+
|
169
|
+
# Define the default class of the input wrapper of the boolean input.
|
170
|
+
config.boolean_label_class = 'checkbox'
|
171
|
+
|
172
|
+
# Defines if the default input wrapper class should be included in radio
|
173
|
+
# collection wrappers.
|
174
|
+
# config.include_default_input_wrapper_class = true
|
175
|
+
|
176
|
+
# Defines which i18n scope will be used in Simple Form.
|
177
|
+
# config.i18n_scope = 'simple_form'
|
178
|
+
|
179
|
+
# Defines validation classes to the input_field. By default it's nil.
|
180
|
+
# config.input_field_valid_class = 'is-valid'
|
181
|
+
# config.input_field_error_class = 'is-invalid'
|
182
|
+
end
|
@@ -0,0 +1,513 @@
|
|
1
|
+
# The first thing you need to configure is which modules you need in your app.
|
2
|
+
# The default is nothing which will include only core features (password encryption, login/logout).
|
3
|
+
# Available submodules are: :user_activation, :http_basic_auth, :remember_me,
|
4
|
+
# :reset_password, :session_timeout, :brute_force_protection, :activity_logging, :external
|
5
|
+
Rails.application.config.sorcery.submodules = [:remember_me, :reset_password, :user_activation, :session_timeout, :brute_force_protection, :activity_logging, :external]
|
6
|
+
|
7
|
+
# Here you can configure each submodule's features.
|
8
|
+
Rails.application.config.sorcery.configure do |config|
|
9
|
+
# -- core --
|
10
|
+
# What controller action to call for non-authenticated users. You can also
|
11
|
+
# override the 'not_authenticated' method of course.
|
12
|
+
# Default: `:not_authenticated`
|
13
|
+
#
|
14
|
+
# config.not_authenticated_action =
|
15
|
+
|
16
|
+
# When a non logged in user tries to enter a page that requires login, save
|
17
|
+
# the URL he wanted to reach, and send him there after login, using 'redirect_back_or_to'.
|
18
|
+
# Default: `true`
|
19
|
+
#
|
20
|
+
# config.save_return_to_url =
|
21
|
+
|
22
|
+
# Set domain option for cookies; Useful for remember_me submodule.
|
23
|
+
# Default: `nil`
|
24
|
+
#
|
25
|
+
# config.cookie_domain =
|
26
|
+
|
27
|
+
# Allow the remember_me cookie to be set through AJAX
|
28
|
+
# Default: `true`
|
29
|
+
#
|
30
|
+
# config.remember_me_httponly =
|
31
|
+
|
32
|
+
# Set token randomness. (e.g. user activation tokens)
|
33
|
+
# The length of the result string is about 4/3 of `token_randomness`.
|
34
|
+
# Default: `15`
|
35
|
+
#
|
36
|
+
# config.token_randomness =
|
37
|
+
|
38
|
+
# -- session timeout --
|
39
|
+
# How long in seconds to keep the session alive.
|
40
|
+
# Default: `3600`
|
41
|
+
#
|
42
|
+
# config.session_timeout =
|
43
|
+
|
44
|
+
# Use the last action as the beginning of session timeout.
|
45
|
+
# Default: `false`
|
46
|
+
#
|
47
|
+
# config.session_timeout_from_last_action =
|
48
|
+
|
49
|
+
# -- http_basic_auth --
|
50
|
+
# What realm to display for which controller name. For example {"My App" => "Application"}
|
51
|
+
# Default: `{"application" => "Application"}`
|
52
|
+
#
|
53
|
+
# config.controller_to_realm_map =
|
54
|
+
|
55
|
+
# -- activity logging --
|
56
|
+
# will register the time of last user login, every login.
|
57
|
+
# Default: `true`
|
58
|
+
#
|
59
|
+
# config.register_login_time =
|
60
|
+
|
61
|
+
# will register the time of last user logout, every logout.
|
62
|
+
# Default: `true`
|
63
|
+
#
|
64
|
+
# config.register_logout_time =
|
65
|
+
|
66
|
+
# will register the time of last user action, every action.
|
67
|
+
# Default: `true`
|
68
|
+
#
|
69
|
+
# config.register_last_activity_time =
|
70
|
+
|
71
|
+
# -- external --
|
72
|
+
# What providers are supported by this app, i.e. [:twitter, :facebook, :github, :linkedin, :xing, :google, :liveid, :salesforce, :slack] .
|
73
|
+
# Default: `[]`
|
74
|
+
#
|
75
|
+
# config.external_providers =
|
76
|
+
|
77
|
+
# You can change it by your local ca_file. i.e. '/etc/pki/tls/certs/ca-bundle.crt'
|
78
|
+
# Path to ca_file. By default use a internal ca-bundle.crt.
|
79
|
+
# Default: `'path/to/ca_file'`
|
80
|
+
#
|
81
|
+
# config.ca_file =
|
82
|
+
|
83
|
+
# For information about LinkedIn API:
|
84
|
+
# - user info fields go to https://developer.linkedin.com/documents/profile-fields
|
85
|
+
# - access permissions go to https://developer.linkedin.com/documents/authentication#granting
|
86
|
+
#
|
87
|
+
# config.linkedin.key = ""
|
88
|
+
# config.linkedin.secret = ""
|
89
|
+
# config.linkedin.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=linkedin"
|
90
|
+
# config.linkedin.user_info_fields = ['first-name', 'last-name']
|
91
|
+
# config.linkedin.user_info_mapping = {first_name: "firstName", last_name: "lastName"}
|
92
|
+
# config.linkedin.access_permissions = ['r_basicprofile']
|
93
|
+
#
|
94
|
+
#
|
95
|
+
# For information about XING API:
|
96
|
+
# - user info fields go to https://dev.xing.com/docs/get/users/me
|
97
|
+
#
|
98
|
+
# config.xing.key = ""
|
99
|
+
# config.xing.secret = ""
|
100
|
+
# config.xing.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=xing"
|
101
|
+
# config.xing.user_info_mapping = {first_name: "first_name", last_name: "last_name"}
|
102
|
+
#
|
103
|
+
#
|
104
|
+
# Twitter will not accept any requests nor redirect uri containing localhost,
|
105
|
+
# make sure you use 0.0.0.0:3000 to access your app in development
|
106
|
+
#
|
107
|
+
# config.twitter.key = ""
|
108
|
+
# config.twitter.secret = ""
|
109
|
+
# config.twitter.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=twitter"
|
110
|
+
# config.twitter.user_info_mapping = {:email => "screen_name"}
|
111
|
+
#
|
112
|
+
# config.facebook.key = ""
|
113
|
+
# config.facebook.secret = ""
|
114
|
+
# config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook"
|
115
|
+
# config.facebook.user_info_path = "me?fields=email"
|
116
|
+
# config.facebook.user_info_mapping = {:email => "email"}
|
117
|
+
# config.facebook.access_permissions = ["email", "publish_actions"]
|
118
|
+
# config.facebook.display = "page"
|
119
|
+
# config.facebook.api_version = "v2.3"
|
120
|
+
# config.facebook.parse = :json
|
121
|
+
#
|
122
|
+
# config.github.key = ""
|
123
|
+
# config.github.secret = ""
|
124
|
+
# config.github.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=github"
|
125
|
+
# config.github.user_info_mapping = {:email => "name"}
|
126
|
+
# config.github.scope = ""
|
127
|
+
#
|
128
|
+
# config.paypal.key = ""
|
129
|
+
# config.paypal.secret = ""
|
130
|
+
# config.paypal.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=paypal"
|
131
|
+
# config.paypal.user_info_mapping = {:email => "email"}
|
132
|
+
#
|
133
|
+
# config.wechat.key = ""
|
134
|
+
# config.wechat.secret = ""
|
135
|
+
# config.wechat.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=wechat"
|
136
|
+
#
|
137
|
+
# config.google.key = ""
|
138
|
+
# config.google.secret = ""
|
139
|
+
# config.google.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=google"
|
140
|
+
# config.google.user_info_mapping = {:email => "email", :username => "name"}
|
141
|
+
# config.google.scope = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
|
142
|
+
#
|
143
|
+
# For Microsoft Graph, the key will be your App ID, and the secret will be your app password/public key.
|
144
|
+
# The callback URL "can't contain a query string or invalid special characters", see: https://docs.microsoft.com/en-us/azure/active-directory/active-directory-v2-limitations#restrictions-on-redirect-uris
|
145
|
+
# More information at https://graph.microsoft.io/en-us/docs
|
146
|
+
#
|
147
|
+
# config.microsoft.key = ""
|
148
|
+
# config.microsoft.secret = ""
|
149
|
+
# config.microsoft.callback_url = "http://0.0.0.0:3000/oauth/callback/microsoft"
|
150
|
+
# config.microsoft.user_info_mapping = {:email => "userPrincipalName", :username => "displayName"}
|
151
|
+
# config.microsoft.scope = "openid email https://graph.microsoft.com/User.Read"
|
152
|
+
#
|
153
|
+
# config.vk.key = ""
|
154
|
+
# config.vk.secret = ""
|
155
|
+
# config.vk.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=vk"
|
156
|
+
# config.vk.user_info_mapping = {:login => "domain", :name => "full_name"}
|
157
|
+
# config.vk.api_version = "5.71"
|
158
|
+
#
|
159
|
+
# config.slack.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=slack"
|
160
|
+
# config.slack.key = ''
|
161
|
+
# config.slack.secret = ''
|
162
|
+
# config.slack.user_info_mapping = {email: 'email'}
|
163
|
+
#
|
164
|
+
# To use liveid in development mode you have to replace mydomain.com with
|
165
|
+
# a valid domain even in development. To use a valid domain in development
|
166
|
+
# simply add your domain in your /etc/hosts file in front of 127.0.0.1
|
167
|
+
#
|
168
|
+
# config.liveid.key = ""
|
169
|
+
# config.liveid.secret = ""
|
170
|
+
# config.liveid.callback_url = "http://mydomain.com:3000/oauth/callback?provider=liveid"
|
171
|
+
# config.liveid.user_info_mapping = {:username => "name"}
|
172
|
+
|
173
|
+
# For information about JIRA API:
|
174
|
+
# https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+OAuth+authentication
|
175
|
+
# to obtain the consumer key and the public key you can use the jira-ruby gem https://github.com/sumoheavy/jira-ruby
|
176
|
+
# or run openssl req -x509 -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem to obtain the public key
|
177
|
+
# Make sure you have configured the application link properly
|
178
|
+
|
179
|
+
# config.jira.key = "1234567"
|
180
|
+
# config.jira.secret = "jiraTest"
|
181
|
+
# config.jira.site = "http://localhost:2990/jira/plugins/servlet/oauth"
|
182
|
+
# config.jira.signature_method = "RSA-SHA1"
|
183
|
+
# config.jira.private_key_file = "rsakey.pem"
|
184
|
+
|
185
|
+
# For information about Salesforce API:
|
186
|
+
# https://developer.salesforce.com/signup &
|
187
|
+
# https://www.salesforce.com/us/developer/docs/api_rest/
|
188
|
+
# Salesforce callback_url must be https. You can run the following to generate self-signed ssl cert
|
189
|
+
# openssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout server.key -out server.crt
|
190
|
+
# Make sure you have configured the application link properly
|
191
|
+
# config.salesforce.key = '123123'
|
192
|
+
# config.salesforce.secret = 'acb123'
|
193
|
+
# config.salesforce.callback_url = "https://127.0.0.1:9292/oauth/callback?provider=salesforce"
|
194
|
+
# config.salesforce.scope = "full"
|
195
|
+
# config.salesforce.user_info_mapping = {:email => "email"}
|
196
|
+
|
197
|
+
# --- user config ---
|
198
|
+
config.user_config do |user|
|
199
|
+
# -- core --
|
200
|
+
# specify username attributes, for example: [:username, :email].
|
201
|
+
# Default: `[:email]`
|
202
|
+
#
|
203
|
+
# user.username_attribute_names =
|
204
|
+
|
205
|
+
# change *virtual* password attribute, the one which is used until an encrypted one is generated.
|
206
|
+
# Default: `:password`
|
207
|
+
#
|
208
|
+
# user.password_attribute_name =
|
209
|
+
|
210
|
+
# downcase the username before trying to authenticate, default is false
|
211
|
+
# Default: `false`
|
212
|
+
#
|
213
|
+
# user.downcase_username_before_authenticating =
|
214
|
+
|
215
|
+
# change default email attribute.
|
216
|
+
# Default: `:email`
|
217
|
+
#
|
218
|
+
# user.email_attribute_name =
|
219
|
+
|
220
|
+
# change default crypted_password attribute.
|
221
|
+
# Default: `:crypted_password`
|
222
|
+
#
|
223
|
+
# user.crypted_password_attribute_name =
|
224
|
+
|
225
|
+
# what pattern to use to join the password with the salt
|
226
|
+
# Default: `""`
|
227
|
+
#
|
228
|
+
# user.salt_join_token =
|
229
|
+
|
230
|
+
# change default salt attribute.
|
231
|
+
# Default: `:salt`
|
232
|
+
#
|
233
|
+
# user.salt_attribute_name =
|
234
|
+
|
235
|
+
# how many times to apply encryption to the password.
|
236
|
+
# Default: 1 in test env, `nil` otherwise
|
237
|
+
#
|
238
|
+
user.stretches = 1 if Rails.env.test?
|
239
|
+
|
240
|
+
# encryption key used to encrypt reversible encryptions such as AES256.
|
241
|
+
# WARNING: If used for users' passwords, changing this key will leave passwords undecryptable!
|
242
|
+
# Default: `nil`
|
243
|
+
#
|
244
|
+
# user.encryption_key =
|
245
|
+
|
246
|
+
# use an external encryption class.
|
247
|
+
# Default: `nil`
|
248
|
+
#
|
249
|
+
# user.custom_encryption_provider =
|
250
|
+
|
251
|
+
# encryption algorithm name. See 'encryption_algorithm=' for available options.
|
252
|
+
# Default: `:bcrypt`
|
253
|
+
#
|
254
|
+
# user.encryption_algorithm =
|
255
|
+
|
256
|
+
# make this configuration inheritable for subclasses. Useful for ActiveRecord's STI.
|
257
|
+
# Default: `false`
|
258
|
+
#
|
259
|
+
# user.subclasses_inherit_config =
|
260
|
+
|
261
|
+
# -- remember_me --
|
262
|
+
# How long in seconds the session length will be
|
263
|
+
# Default: `604800`
|
264
|
+
#
|
265
|
+
# user.remember_me_for =
|
266
|
+
|
267
|
+
# when true sorcery will persist a single remember me token for all
|
268
|
+
# logins/logouts (supporting remembering on multiple browsers simultaneously).
|
269
|
+
# Default: false
|
270
|
+
#
|
271
|
+
# user.remember_me_token_persist_globally =
|
272
|
+
|
273
|
+
# -- user_activation --
|
274
|
+
# the attribute name to hold activation state (active/pending).
|
275
|
+
# Default: `:activation_state`
|
276
|
+
#
|
277
|
+
# user.activation_state_attribute_name =
|
278
|
+
|
279
|
+
# the attribute name to hold activation code (sent by email).
|
280
|
+
# Default: `:activation_token`
|
281
|
+
#
|
282
|
+
# user.activation_token_attribute_name =
|
283
|
+
|
284
|
+
# the attribute name to hold activation code expiration date.
|
285
|
+
# Default: `:activation_token_expires_at`
|
286
|
+
#
|
287
|
+
# user.activation_token_expires_at_attribute_name =
|
288
|
+
|
289
|
+
# how many seconds before the activation code expires. nil for never expires.
|
290
|
+
# Default: `nil`
|
291
|
+
#
|
292
|
+
# user.activation_token_expiration_period =
|
293
|
+
|
294
|
+
# your mailer class. Required.
|
295
|
+
# Default: `nil`
|
296
|
+
#
|
297
|
+
user.user_activation_mailer = Morpho::UserMailer
|
298
|
+
|
299
|
+
# when true sorcery will not automatically
|
300
|
+
# email activation details and allow you to
|
301
|
+
# manually handle how and when email is sent.
|
302
|
+
# Default: `false`
|
303
|
+
#
|
304
|
+
# user.activation_mailer_disabled =
|
305
|
+
|
306
|
+
# method to send email related
|
307
|
+
# options: `:deliver_later`, `:deliver_now`, `:deliver`
|
308
|
+
# Default: :deliver (Rails version < 4.2) or :deliver_now (Rails version 4.2+)
|
309
|
+
#
|
310
|
+
# user.email_delivery_method =
|
311
|
+
|
312
|
+
# activation needed email method on your mailer class.
|
313
|
+
# Default: `:activation_needed_email`
|
314
|
+
#
|
315
|
+
# user.activation_needed_email_method_name =
|
316
|
+
|
317
|
+
# activation success email method on your mailer class.
|
318
|
+
# Default: `:activation_success_email`
|
319
|
+
#
|
320
|
+
# user.activation_success_email_method_name =
|
321
|
+
|
322
|
+
# do you want to prevent or allow users that did not activate by email to login?
|
323
|
+
# Default: `true`
|
324
|
+
#
|
325
|
+
# user.prevent_non_active_users_to_login =
|
326
|
+
|
327
|
+
# -- reset_password --
|
328
|
+
# reset password code attribute name.
|
329
|
+
# Default: `:reset_password_token`
|
330
|
+
#
|
331
|
+
# user.reset_password_token_attribute_name =
|
332
|
+
|
333
|
+
# expires at attribute name.
|
334
|
+
# Default: `:reset_password_token_expires_at`
|
335
|
+
#
|
336
|
+
# user.reset_password_token_expires_at_attribute_name =
|
337
|
+
|
338
|
+
# when was email sent, used for hammering protection.
|
339
|
+
# Default: `:reset_password_email_sent_at`
|
340
|
+
#
|
341
|
+
# user.reset_password_email_sent_at_attribute_name =
|
342
|
+
|
343
|
+
# mailer class. Needed.
|
344
|
+
# Default: `nil`
|
345
|
+
#
|
346
|
+
user.reset_password_mailer = Morpho::UserMailer
|
347
|
+
|
348
|
+
# reset password email method on your mailer class.
|
349
|
+
# Default: `:reset_password_email`
|
350
|
+
#
|
351
|
+
# user.reset_password_email_method_name =
|
352
|
+
|
353
|
+
# when true sorcery will not automatically
|
354
|
+
# email password reset details and allow you to
|
355
|
+
# manually handle how and when email is sent
|
356
|
+
# Default: `false`
|
357
|
+
#
|
358
|
+
# user.reset_password_mailer_disabled =
|
359
|
+
|
360
|
+
# how many seconds before the reset request expires. nil for never expires.
|
361
|
+
# Default: `nil`
|
362
|
+
#
|
363
|
+
# user.reset_password_expiration_period =
|
364
|
+
|
365
|
+
# hammering protection, how long in seconds to wait before allowing another email to be sent.
|
366
|
+
# Default: `5 * 60`
|
367
|
+
#
|
368
|
+
# user.reset_password_time_between_emails =
|
369
|
+
|
370
|
+
# access counter to a reset password page attribute name
|
371
|
+
# Default: `:access_count_to_reset_password_page`
|
372
|
+
#
|
373
|
+
# user.reset_password_page_access_count_attribute_name =
|
374
|
+
|
375
|
+
# -- magic_login --
|
376
|
+
# magic login code attribute name.
|
377
|
+
# Default: `:magic_login_token`
|
378
|
+
#
|
379
|
+
# user.magic_login_token_attribute_name =
|
380
|
+
|
381
|
+
|
382
|
+
# expires at attribute name.
|
383
|
+
# Default: `:magic_login_token_expires_at`
|
384
|
+
#
|
385
|
+
# user.magic_login_token_expires_at_attribute_name =
|
386
|
+
|
387
|
+
|
388
|
+
# when was email sent, used for hammering protection.
|
389
|
+
# Default: `:magic_login_email_sent_at`
|
390
|
+
#
|
391
|
+
# user.magic_login_email_sent_at_attribute_name =
|
392
|
+
|
393
|
+
|
394
|
+
# mailer class. Needed.
|
395
|
+
# Default: `nil`
|
396
|
+
#
|
397
|
+
# user.magic_login_mailer_class =
|
398
|
+
|
399
|
+
|
400
|
+
# magic login email method on your mailer class.
|
401
|
+
# Default: `:magic_login_email`
|
402
|
+
#
|
403
|
+
# user.magic_login_email_method_name =
|
404
|
+
|
405
|
+
|
406
|
+
# when true sorcery will not automatically
|
407
|
+
# email magic login details and allow you to
|
408
|
+
# manually handle how and when email is sent
|
409
|
+
# Default: `true`
|
410
|
+
#
|
411
|
+
# user.magic_login_mailer_disabled =
|
412
|
+
|
413
|
+
|
414
|
+
# how many seconds before the request expires. nil for never expires.
|
415
|
+
# Default: `nil`
|
416
|
+
#
|
417
|
+
# user.magic_login_expiration_period =
|
418
|
+
|
419
|
+
|
420
|
+
# hammering protection, how long in seconds to wait before allowing another email to be sent.
|
421
|
+
# Default: `5 * 60`
|
422
|
+
#
|
423
|
+
# user.magic_login_time_between_emails =
|
424
|
+
|
425
|
+
# -- brute_force_protection --
|
426
|
+
# Failed logins attribute name.
|
427
|
+
# Default: `:failed_logins_count`
|
428
|
+
#
|
429
|
+
# user.failed_logins_count_attribute_name =
|
430
|
+
|
431
|
+
# This field indicates whether user is banned and when it will be active again.
|
432
|
+
# Default: `:lock_expires_at`
|
433
|
+
#
|
434
|
+
# user.lock_expires_at_attribute_name =
|
435
|
+
|
436
|
+
# How many failed logins allowed.
|
437
|
+
# Default: `50`
|
438
|
+
#
|
439
|
+
user.consecutive_login_retries_amount_limit = Morpho.config.auth.failed_login_attempts_limit
|
440
|
+
|
441
|
+
# How long the user should be banned. in seconds. 0 for permanent.
|
442
|
+
# Default: `60 * 60`
|
443
|
+
#
|
444
|
+
# user.login_lock_time_period =
|
445
|
+
|
446
|
+
# Unlock token attribute name
|
447
|
+
# Default: `:unlock_token`
|
448
|
+
#
|
449
|
+
# user.unlock_token_attribute_name =
|
450
|
+
|
451
|
+
# Unlock token mailer method
|
452
|
+
# Default: `:send_unlock_token_email`
|
453
|
+
#
|
454
|
+
user.unlock_token_email_method_name = :unlock_token_email
|
455
|
+
|
456
|
+
# when true sorcery will not automatically
|
457
|
+
# send email with unlock token
|
458
|
+
# Default: `false`
|
459
|
+
#
|
460
|
+
# user.unlock_token_mailer_disabled = true
|
461
|
+
|
462
|
+
# Unlock token mailer class
|
463
|
+
# Default: `nil`
|
464
|
+
#
|
465
|
+
user.unlock_token_mailer = Morpho::UserMailer
|
466
|
+
|
467
|
+
# -- activity logging --
|
468
|
+
# Last login attribute name.
|
469
|
+
# Default: `:last_login_at`
|
470
|
+
#
|
471
|
+
# user.last_login_at_attribute_name =
|
472
|
+
|
473
|
+
# Last logout attribute name.
|
474
|
+
# Default: `:last_logout_at`
|
475
|
+
#
|
476
|
+
# user.last_logout_at_attribute_name =
|
477
|
+
|
478
|
+
# Last activity attribute name.
|
479
|
+
# Default: `:last_activity_at`
|
480
|
+
#
|
481
|
+
# user.last_activity_at_attribute_name =
|
482
|
+
|
483
|
+
# How long since last activity is the user defined logged out?
|
484
|
+
# Default: `10 * 60`
|
485
|
+
#
|
486
|
+
# user.activity_timeout =
|
487
|
+
|
488
|
+
# -- external --
|
489
|
+
# Class which holds the various external provider data for this user.
|
490
|
+
# Default: `nil`
|
491
|
+
#
|
492
|
+
user.authentications_class = Morpho::Authentication
|
493
|
+
|
494
|
+
# User's identifier in authentications class.
|
495
|
+
# Default: `:user_id`
|
496
|
+
#
|
497
|
+
# user.authentications_user_id_attribute_name =
|
498
|
+
|
499
|
+
# Provider's identifier in authentications class.
|
500
|
+
# Default: `:provider`
|
501
|
+
#
|
502
|
+
# user.provider_attribute_name =
|
503
|
+
|
504
|
+
# User's external unique identifier in authentications class.
|
505
|
+
# Default: `:uid`
|
506
|
+
#
|
507
|
+
# user.provider_uid_attribute_name =
|
508
|
+
end
|
509
|
+
|
510
|
+
# This line must come after the 'user config' block.
|
511
|
+
# Define which model authenticates with sorcery.
|
512
|
+
config.user_class = Morpho::User
|
513
|
+
end
|