Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5bf4415
Add rack-timeout
zachmargolis Aug 31, 2017
e092089
Increase timeout to 30s
zachmargolis Aug 31, 2017
e973ca9
Merge pull request #1656 from 18F/margolis-rack-timeout
zachmargolis Sep 5, 2017
ea4f619
Filter headers via Middleware
zachmargolis Sep 8, 2017
7d48ba6
Keep locale when cancelling SP-initiated signup
zachmargolis Sep 8, 2017
e3b442c
Redact more phone numbers in error messages
zachmargolis Sep 8, 2017
073261f
Merge pull request #1663 from 18F/margolis-correct-host
zachmargolis Sep 8, 2017
5c3ea90
Allow multiple USPS confirmation codes
jmhooper Sep 6, 2017
b1bcd64
Merge pull request #1661 from 18F/jmhooper-remove-otp-from-encrypted-…
jmhooper Sep 8, 2017
7bd5ef9
Merge pull request #1664 from 18F/margolis-more-twilio-redact
zachmargolis Sep 8, 2017
dd3d845
Merge pull request #1662 from 18F/margolis-cancel-persist-language
zachmargolis Sep 8, 2017
6df4d17
Revert "Remove cron dependency for worker health checker"
zachmargolis Sep 11, 2017
497d391
Merge pull request #1667 from 18F/revert-1638-margolis-health-check-w…
zachmargolis Sep 11, 2017
b651a65
Specify telephony service in specs
monfresh Sep 11, 2017
5962495
Merge pull request #1669 from 18F/mb-fix-twilio-service-spec
monfresh Sep 11, 2017
8f8f0bf
Ignore production and deploy gems for local dev
monfresh Sep 11, 2017
deb3f3e
Merge pull request #1668 from 18F/mb-improve-setup-script
monfresh Sep 11, 2017
effdd71
Change prod emails from mailchimp to SES
jmhooper Aug 29, 2017
577cdf2
Merge pull request #1651 from 18F/jmhooper-switch-to-ses
jmhooper Sep 14, 2017
b43c871
Remove HTTP Host header entirely
zachmargolis Sep 14, 2017
1f6afcd
Merge pull request #1672 from 18F/margolis-host-headers
zachmargolis Sep 14, 2017
be2ba20
Gracefully handle unknown formats
zachmargolis Sep 14, 2017
153f6a9
Merge pull request #1671 from 18F/margolis-handle-unknown-format
zachmargolis Sep 14, 2017
759f522
Sanitize UTF8 characters from headers
jmhooper Sep 14, 2017
1fcbf66
Merge pull request #1674 from 18F/jmhooper-header-encoding
jmhooper Sep 15, 2017
091c8b3
Allow running any ruby 2.3 version.
brodygov Sep 16, 2017
4d4b300
Enforce ruby ~> 2.3.5 upgrade.
brodygov Sep 16, 2017
6c383e9
Seems like CircleCI may not have 2.3.5.
brodygov Sep 16, 2017
804c60d
Set all existing migrations as being from Rails 4.
brodygov Sep 16, 2017
8456dc0
Merge pull request #1676 from 18F/brody/migration-versions
zachmargolis Sep 18, 2017
64cb474
Merge pull request #1675 from 18F/brody/ruby-2.3-latest
monfresh Sep 18, 2017
341d131
Update personal key UI
monfresh Sep 5, 2017
be4f52a
Merge pull request #1659 from 18F/mb-update-personal-key-ui
monfresh Sep 18, 2017
8610a01
Merge pull request #1691 from 18F/jmhooper-disable-international-voice
jmhooper Sep 25, 2017
64b995b
Merge pull request #1693 from 18F/jmhooper-enable-mexico-calling
jmhooper Sep 27, 2017
c40a2dd
Merge pull request #1703 from 18F/stages/prod
jmhooper Sep 28, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
docker:
# Specify the Ruby version you desire here
- image: circleci/ruby:2.3.3-node-browsers
- image: circleci/ruby:2.3.5-node-browsers
environment:
RAILS_ENV: test
CC_TEST_REPORTER_ID: faecd27e9aed532634b3f4d3e251542d7de9457cfca96a94208a63270ef9b42e
Expand Down
1 change: 1 addition & 0 deletions .reek
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ DuplicateMethodCall:
FeatureEnvy:
exclude:
- ActiveJob::Logging::LogSubscriber#json_for
- Aws::SES::Base#deliver
- track_registration
- append_info_to_payload
- generate_slo_request
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.3
2.3
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the official Ruby image because the Rails images have been deprecated
FROM ruby:2.3.3
FROM ruby:2.3

# npm is needed by browserify to install packages
# TOOD(sbc): Create a separate production container without this.
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }

ruby '~> 2.3.3'
ruby '~> 2.3.5'

gem 'rails', '~> 5.1.3'

Expand Down Expand Up @@ -31,6 +31,8 @@ gem 'phony_rails'
gem 'premailer-rails'
gem 'proofer', github: '18F/identity-proofer-gem', branch: 'master'
gem 'rack-cors', require: 'rack/cors'
gem 'rack-headers_filter'
gem 'rack-timeout'
gem 'readthis'
gem 'redis-session-store', github: '18F/redis-session-store', branch: 'master'
gem 'rqrcode'
Expand Down
14 changes: 9 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ GEM
erubi (1.6.1)
erubis (2.7.0)
eventmachine (1.2.5)
excon (0.57.0)
excon (0.58.0)
execjs (2.7.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -415,12 +415,14 @@ GEM
rack-attack (5.0.1)
rack
rack-cors (0.4.1)
rack-headers_filter (0.0.1)
rack-mini-profiler (0.10.5)
rack (>= 1.2.0)
rack-protection (2.0.0)
rack
rack-test (0.6.3)
rack (>= 1.0)
rack-timeout (0.4.2)
rack_session_access (0.1.1)
builder (>= 2.0.0)
rack (>= 1.0.0)
Expand Down Expand Up @@ -513,8 +515,8 @@ GEM
ruby-saml (1.4.3)
nokogiri (>= 1.5.10)
ruby_dep (1.5.0)
ruby_parser (3.8.4)
sexp_processor (~> 4.1)
ruby_parser (3.10.1)
sexp_processor (~> 4.9)
safe_yaml (1.0.4)
safely_block (0.2.0)
errbase
Expand All @@ -538,7 +540,7 @@ GEM
secure_headers (3.6.7)
useragent
securecompare (1.0.0)
sexp_processor (4.8.0)
sexp_processor (4.10.0)
shellany (0.0.1)
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
Expand Down Expand Up @@ -713,8 +715,10 @@ DEPENDENCIES
proofer!
pry-byebug
rack-cors
rack-headers_filter
rack-mini-profiler
rack-test
rack-timeout
rack_session_access
rails (~> 5.1.3)
rails-controller-testing
Expand Down Expand Up @@ -755,7 +759,7 @@ DEPENDENCIES
zxcvbn-js

RUBY VERSION
ruby 2.3.3p222
ruby 2.3.5p376

BUNDLED WITH
1.15.4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A Identity Management System powering login.gov.

#### Dependencies

- Ruby 2.3.3
- Ruby 2.3
- [Postgresql](http://www.postgresql.org/download/)
- [Redis 2.8+](http://redis.io/)
- [Node.js v4.4.x](https://nodejs.org)
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/components/_btn.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
&:active,
&:focus,
&:hover, {
border: 0;
box-shadow: none;
text-decoration: underline;
}
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

rescue_from ActionController::InvalidAuthenticityToken, with: :invalid_auth_token
rescue_from ActionController::UnknownFormat, with: :render_not_found

helper_method :decorated_session, :reauthn?, :user_fully_authenticated?

Expand Down Expand Up @@ -151,4 +152,8 @@ def set_locale
def sp_session
session.fetch(:sp, {})
end

def render_not_found
render template: 'pages/page_not_found', layout: false, status: 404, formats: :html
end
end
2 changes: 0 additions & 2 deletions app/controllers/health/workers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Health
class WorkersController < ApplicationController
def index
WorkerHealthChecker.enqueue_dummy_jobs

summary = WorkerHealthChecker.summary

status = summary.all_healthy? ? :ok : :internal_error
Expand Down
15 changes: 12 additions & 3 deletions app/controllers/users/personal_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,25 @@ class PersonalKeysController < ApplicationController
before_action :confirm_two_factor_authenticated

def show
@code = create_new_code
analytics.track_event(Analytics::PROFILE_PERSONAL_KEY_CREATE)
personal_key = user_session[:personal_key]

return redirect_to account_url if personal_key.blank?

flash.now[:success] = t('notices.send_code.personal_key') if params[:resend].present?
@code = personal_key
end

def update
user_session.delete(:personal_key)
redirect_to next_step
end

def create
user_session[:personal_key] = create_new_code
analytics.track_event(Analytics::PROFILE_PERSONAL_KEY_CREATE)
flash[:success] = t('notices.send_code.personal_key') if params[:resend].present?
redirect_to manage_personal_key_path
end

private

def next_step
Expand Down
12 changes: 2 additions & 10 deletions app/controllers/users/verify_account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index
@verify_account_form = VerifyAccountForm.new(user: current_user)

return unless FeatureManagement.reveal_usps_code?
@code = JSON.parse(user_session[:decrypted_pii])['otp']['raw']
@code = session[:last_usps_confirmation_code]
end

def create
Expand All @@ -28,8 +28,7 @@ def create
def build_verify_account_form
VerifyAccountForm.new(
user: current_user,
otp: params_otp,
pii_attributes: decrypted_pii
otp: params_otp
)
end

Expand All @@ -41,12 +40,5 @@ def confirm_verification_needed
return if current_user.decorate.pending_profile_requires_verification?
redirect_to account_url
end

def decrypted_pii
@_decrypted_pii ||= begin
cacher = Pii::Cacher.new(current_user, user_session)
cacher.fetch
end
end
end
end
11 changes: 3 additions & 8 deletions app/controllers/verify/come_back_later_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ module Verify
class ComeBackLaterController < ApplicationController
include IdvSession

before_action :confirm_idv_session_completed
before_action :confirm_usps_verification_method_chosen
before_action :confirm_user_needs_usps_confirmation

def show; end

private

def confirm_idv_session_completed
redirect_to account_path if idv_session.profile.blank?
end

def confirm_usps_verification_method_chosen
redirect_to account_path unless idv_session.address_verification_mechanism == 'usps'
def confirm_user_needs_usps_confirmation
redirect_to account_path unless current_user.decorate.needs_profile_usps_verification?
end
end
end
3 changes: 3 additions & 0 deletions app/controllers/verify/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def create
init_profile
redirect_to verify_confirmations_path
analytics.track_event(Analytics::IDV_REVIEW_COMPLETE)

return unless FeatureManagement.reveal_usps_code?
session[:last_usps_confirmation_code] = idv_session.usps_otp
end

private
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/verify/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Verify
class SessionsController < ApplicationController
include IdvSession
include IdvFailureConcern
include PersonalKeyConcern

before_action :confirm_two_factor_authenticated, except: [:destroy]
before_action :confirm_idv_attempts_allowed
Expand Down Expand Up @@ -75,6 +76,7 @@ def step

def handle_idv_redirect
redirect_to account_path and return if current_user.personal_key.present?
user_session[:personal_key] = create_new_code
redirect_to manage_personal_key_path
end

Expand Down
15 changes: 14 additions & 1 deletion app/controllers/verify/usps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def create
idv_session.address_verification_mechanism = :usps

if current_user.decorate.needs_profile_usps_verification?
redirect_to account_path
resend_letter
redirect_to verify_come_back_later_url
else
redirect_to verify_review_url
end
Expand All @@ -29,5 +30,17 @@ def confirm_mail_not_spammed
redirect_to verify_review_path if idv_session.address_mechanism_chosen? &&
usps_mail_service.mail_spammed?
end

def resend_letter
confirmation_maker = UspsConfirmationMaker.new(
pii: Pii::Cacher.new(current_user, user_session).fetch,
issuer: sp_session[:issuer],
profile: current_user.decorate.pending_profile
)
confirmation_maker.perform

return unless FeatureManagement.reveal_usps_code?
session[:last_usps_confirmation_code] = confirmation_maker.otp
end
end
end
2 changes: 1 addition & 1 deletion app/decorators/service_provider_session_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def sp_return_url
end

def cancel_link_path
sign_up_start_path(request_id: sp_session[:request_id])
sign_up_start_path(request_id: sp_session[:request_id], locale: locale_url_param)
end

private
Expand Down
15 changes: 9 additions & 6 deletions app/forms/verify_account_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ class VerifyAccountForm
attr_accessor :otp, :pii_attributes
attr_reader :user

def initialize(user:, otp: nil, pii_attributes: nil)
def initialize(user:, otp: nil)
@user = user
@otp = otp
@pii_attributes = pii_attributes
end

def submit
Expand All @@ -31,8 +30,14 @@ def pending_profile
@_pending_profile ||= user.decorate.pending_profile
end

def usps_confirmation_code
return if otp.blank? || pending_profile.blank?

pending_profile.usps_confirmation_codes.first_with_otp(otp)
end

def validate_otp_not_expired
return unless Idv::UspsMail.new(user).most_recent_otp_expired?
return unless usps_confirmation_code.present? && usps_confirmation_code.expired?

errors.add :otp, :usps_otp_expired
end
Expand All @@ -47,9 +52,7 @@ def validate_otp
end

def valid_otp?
otp.present? && ActiveSupport::SecurityUtils.secure_compare(
Base32::Crockford.normalize(otp), Base32::Crockford.normalize(pii_attributes.otp.to_s)
)
otp.present? && usps_confirmation_code.present?
end

def reset_sensitive_fields
Expand Down
9 changes: 0 additions & 9 deletions app/jobs/sms_otp_sender_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,5 @@ def send_otp(twilio_service, code, phone)
to: phone,
body: I18n.t('jobs.sms_otp_sender_job.message', code: code, app: APP_NAME)
)
rescue Twilio::REST::RestError => error
sanitize_phone_number(error.message)
raise
end

def sanitize_phone_number(str)
return unless str =~ /is not a valid phone number/

str.gsub!(/\+[\d\(\)\- ]+/) { |match| match.gsub(/\d/, '#') }
end
end
1 change: 1 addition & 0 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Profile < ApplicationRecord
belongs_to :user
has_many :usps_confirmation_codes

validates :active, uniqueness: { scope: :user_id, if: :active? }
validates :ssn_signature, uniqueness: { scope: :active, if: :active? }
Expand Down
16 changes: 16 additions & 0 deletions app/models/usps_confirmation_code.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class UspsConfirmationCode < ApplicationRecord
belongs_to :profile

def self.first_with_otp(otp)
find do |usps_confirmation_code|
Pii::Fingerprinter.verify(
Base32::Crockford.normalize(otp),
usps_confirmation_code.otp_fingerprint
)
end
end

def expired?
code_sent_at < Figaro.env.usps_confirmation_max_days.to_i.days.ago
end
end
1 change: 0 additions & 1 deletion app/services/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def track_event(event, attributes = {})
event_properties: attributes.except(:user_id),
user_id: attributes[:user_id] || uuid,
}

ahoy.track(event, analytics_hash.merge!(request_attributes))
end

Expand Down
Loading