Skip to content

Commit 708a736

Browse files
committed
Add argon generation
1 parent fd8da9b commit 708a736

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ gem 'rack-mini-profiler', '~> 1.0', '>= 1.0.1'
4747
gem 'flamegraph', '~> 0.9.5'
4848
gem 'stackprof', '~> 0.2.12'
4949
gem 'ruby-kafka', '~> 0.7.10'
50+
gem 'argon2', '~> 2.0', '>= 2.0.2'
5051

5152
group :assets do
5253
gem 'jquery-rails', '~> 3.1.2'

Gemfile.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ GEM
4747
public_suffix (>= 2.0.2, < 4.0)
4848
andand (1.3.3)
4949
arel (6.0.4)
50+
argon2 (2.0.2)
51+
ffi (~> 1.9)
52+
ffi-compiler (>= 0.1)
5053
ast (2.4.0)
5154
autoprefixer-rails (8.2.0)
5255
execjs
@@ -96,6 +99,9 @@ GEM
9699
faraday (0.14.0)
97100
multipart-post (>= 1.2, < 3)
98101
ffi (1.9.23)
102+
ffi-compiler (1.0.1)
103+
ffi (>= 1.0.0)
104+
rake
99105
flamegraph (0.9.5)
100106
font-awesome-rails (4.7.0.3)
101107
railties (>= 3.2, < 5.2)
@@ -376,6 +382,7 @@ DEPENDENCIES
376382
activerecord-import (~> 0.28.1)
377383
activerecord-session_store (~> 1.0.0)
378384
andand
385+
argon2 (~> 2.0, >= 2.0.2)
379386
bootstrap (~> 4.0.0.beta2.1)
380387
brakeman
381388
bundler-audit
@@ -435,4 +442,4 @@ DEPENDENCIES
435442
xml-simple (~> 1.1.1)
436443

437444
BUNDLED WITH
438-
1.17.1
445+
1.17.2

app/models/user.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,8 @@ def reject_common_login_mistakes
330330
errors.add(:email, 'may not end with "@ad.helsinki.fi". You cannot receive any emails with this address -- it\'s only used for your webmail login. Figure out what your real email address is and try again. It is usually of the form [email protected] but verify this first.') if email.end_with?('@ad.helsinki.fi')
331331
errors.add(:email, 'is incorrect. You probably meant [email protected]. Keep in mind that your email address does not contain your University of Helsinki username.') if email.end_with?('@helsinki.fi') && !/.*\..*@helsinki.fi/.match?(email)
332332
end
333+
334+
def _generate_argon
335+
update(argon_hash: Argon2::Password.new(t_cost: 4, m_cost: 15).create(password_hash))
336+
end
333337
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddArgonHash < ActiveRecord::Migration
2+
def change
3+
add_column :users, :argon_hash, :string
4+
end
5+
end

db/schema.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20200112230124) do
14+
ActiveRecord::Schema.define(version: 20200115143302) do
15+
1516
# These are extensions that must be enabled in order to support this database
1617
enable_extension "plpgsql"
1718

@@ -478,6 +479,7 @@
478479
t.text "email", default: "", null: false
479480
t.boolean "legitimate_student", default: true, null: false
480481
t.boolean "email_verified", default: false, null: false
482+
t.string "argon_hash"
481483
end
482484

483485
add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree

0 commit comments

Comments
 (0)