Skip to content

Commit

Permalink
Merge pull request #1499 from 18F/stages/int
Browse files Browse the repository at this point in the history
Deploy int to staging
  • Loading branch information
monfresh authored Jun 22, 2017
2 parents 0f0414f + 606695e commit 0b972c9
Show file tree
Hide file tree
Showing 103 changed files with 1,337 additions and 181 deletions.
12 changes: 11 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
engines:
brakeman:
enabled: true
exclude_paths:
# Excluding User Flows tools since these are not loaded
# except when explicitly called from the User Flow rake tasks
- 'lib/user_flow_exporter.rb'
- 'lib/rspec/formatters/user_flow_formatter.rb'
bundler-audit:
enabled: true
coffeelint:
Expand All @@ -19,6 +24,8 @@ engines:
- 'node_modules/**/*'
- 'db/schema.rb'
- 'app/forms/password_form.rb'
- 'lib/user_flow_exporter.rb'
- 'lib/rspec/formatters/user_flow_formatter.rb'
eslint:
enabled: true
fixme:
Expand All @@ -38,6 +45,8 @@ engines:
exclude_paths:
- 'spec/**/*'
- 'db/migrate/*'
- 'lib/user_flow_exporter.rb'
- 'lib/rspec/formatters/user_flow_formatter.rb'
rubocop:
enabled: true
scss-lint:
Expand All @@ -50,4 +59,5 @@ ratings:
- '**.rb'
- '**.go'
exclude_paths:
- 'lib/rspec/formatters/*'
- 'lib/user_flow_exporter.rb'
- 'lib/rspec/formatters/user_flow_formatter.rb'
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ AllCops:
- 'config/initializers/devise.rb'
- 'db/migrate/*'
- 'spec/services/pii/nist_encryption_spec.rb'
- 'lib/rspec/user_flow_formatter.rb'
- 'lib/user_flow_exporter.rb'
TargetRubyVersion: 2.3
UseCache: true

Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ RUN bundle install --jobs=20 --retry=5 --frozen --without deploy production

COPY . /upaya

RUN gpg --dearmor < keys/equifax_gpg.pub.example > keys/equifax_gpg.pub.bin
RUN gpg --batch --import keys/equifax_gpg.example

EXPOSE 3000
CMD ["rackup", "config.ru", "--host", "0.0.0.0", "--port", "3000"]
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ end

group :development, :test do
gem 'bullet'
gem 'front_matter_parser'
gem 'i18n-tasks'
gem 'mailcatcher', require: false
gem 'pry-byebug'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ GEM
thor (~> 0.14)
formatador (0.2.5)
foundation_emails (2.2.1.0)
front_matter_parser (0.1.0)
geocoder (1.4.4)
get_process_mem (0.2.1)
gibberish (2.1.0)
Expand Down Expand Up @@ -678,6 +679,7 @@ DEPENDENCIES
fasterer
figaro
foundation_emails
front_matter_parser
gibberish
guard-rspec
gyoku
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ $ RAILS_ASSET_HOST=localhost:3000 rake spec:user_flows

Then, visit http://localhost:3000/user_flows in your browser!

##### Exporting

The user flows tool also has an export feature which allows you to export everything for the web. You may host these assets with someting like [`simplehttpserver`](https://www.npmjs.com/package/simplehttpserver) or publish to [Federalist](https://federalist.18f.gov/). To publish user flows for Federalist, first make sure the application is running locally (eg. localhost:3000) and run:

```
$ RAILS_ASSET_HOST=localhost:3000 FEDERALIST_PATH=/site/user/repository rake spec:user_flows:web
```

This will output your site to `public/site/user/repository` for quick publishing to [Federalist](https://federalist-docs.18f.gov/pages/using-federalist/). To test compatibility, run `simplehttpserver` from the app's `public` folder and visit `http://localhost:8000/<FEDERALIST PATH>/user_flows` in your browser.

### Load testing

We provide some [Locust.io] Python scripts you can run to test how the
Expand Down
23 changes: 23 additions & 0 deletions app/assets/images/sp-logos/square-gsa-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions app/assets/images/sp-logos/square-gsa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/stylesheets/components/_background.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
@media #{$breakpoint-sm} {
.sm-bg-light-blue { background-color: $blue-light; }
.sm-bg-none { background-color: transparent; }
.sm-bg-navy { background-color: $navy; }
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/components/_color.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@media #{$breakpoint-sm} {
.sm-white { color: $white; }
}
11 changes: 11 additions & 0 deletions app/assets/stylesheets/components/_util.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
vertical-align: middle;
}


.block-center {
margin: 0 auto;
}

.scale-down {
// trigger anti-aliasing in chrome
backface-visibility: hidden;
transform: scale(.7);
}

@media #{$breakpoint-sm} {
// scss-lint:disable ImportantRule
.sm-display-inline-block { display: inline-block !important; }
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/components/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import 'border';
@import 'btn';
@import 'card';
@import 'color';
@import 'container';
@import 'footer';
@import 'form';
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/concerns/idv_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ def confirm_idv_vendor_session_started
end

def idv_session
@_idv_session ||= Idv::Session.new(user_session, current_user)
@_idv_session ||= Idv::Session.new(
user_session: user_session,
current_user: current_user,
issuer: sp_session[:issuer]
)
end

def idv_vendor
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/concerns/two_factor_authenticatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ def update_phone_attributes
def update_idv_state
now = Time.zone.now
if idv_context?
Idv::Session.new(user_session, current_user).params['phone_confirmed_at'] = now
Idv::Session.new(
user_session: user_session,
current_user: current_user,
issuer: sp_session[:issuer]
).params['phone_confirmed_at'] = now
elsif profile_context?
Idv::ProfileActivator.new(user: current_user).call
end
Expand Down Expand Up @@ -186,7 +190,7 @@ def after_otp_action_path
elsif @updating_existing_number
account_path
elsif decorated_user.password_reset_profile.present?
reactivate_account_path
manage_reactivate_account_path
else
account_path
end
Expand Down
20 changes: 20 additions & 0 deletions app/controllers/reactivate_account_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class ReactivateAccountController < ApplicationController
before_action :confirm_two_factor_authenticated
before_action :confirm_password_reset_profile

def index
user_session[:acknowledge_personal_key] ||= true
end

def update
user_session.delete(:acknowledge_personal_key)
redirect_to verify_url
end

protected

def confirm_password_reset_profile
return if current_user.decorate.password_reset_profile
redirect_to root_url
end
end
3 changes: 2 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class UsersController < ApplicationController
def destroy
path_after_cancellation = decorated_session.cancel_link_path
destroy_user
flash[:success] = t('sign_up.cancel.success')
redirect_to root_path
redirect_to path_after_cancellation
end

private
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/verify_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class VerifyController < ApplicationController

before_action :confirm_two_factor_authenticated
before_action :confirm_idv_needed, only: %i[cancel fail]
before_action :profile_needs_reactivation?, only: [:index]

def index
if active_profile?
Expand All @@ -26,6 +27,15 @@ def fail

private

def profile_needs_reactivation?
return unless password_reset_profile && user_session[:acknowledge_personal_key] == true
redirect_to manage_reactivate_account_url
end

def password_reset_profile
current_user.decorate.password_reset_profile
end

def active_profile?
current_user.active_profile.present?
end
Expand Down
6 changes: 3 additions & 3 deletions app/decorators/service_provider_session_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def sp_name
end

def sp_return_url
if sp.redirect_uri.present? && openid_connect_redirector.valid?
if sp.redirect_uris.present? && openid_connect_redirector.valid?
openid_connect_redirector.decline_redirect_uri
else
sp.return_to_sp_url
end
end

def cancel_link_url
sign_up_start_url(request_id: sp_session[:request_id])
def cancel_link_path
sign_up_start_path(request_id: sp_session[:request_id])
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/session_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def sp_return_url; end

def requested_attributes; end

def cancel_link_url
root_url
def cancel_link_path
root_path
end
end
2 changes: 1 addition & 1 deletion app/forms/openid_connect_authorize_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def loa3_requested?
end

def sp_redirect_uri
service_provider.redirect_uri
openid_connect_redirector.validated_input_redirect_uri
end

def service_provider
Expand Down
1 change: 1 addition & 0 deletions app/forms/reactivate_account_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def decrypted_pii
def reencrypt_pii
personal_key = password_reset_profile.encrypt_pii(user_access_key, decrypted_pii)
password_reset_profile.deactivation_reason = nil
password_reset_profile.active = true
password_reset_profile.save!
personal_key
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/null_service_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ def friendly_name; end

def return_to_sp_url; end

def redirect_uri; end
def redirect_uris
[]
end
end
4 changes: 4 additions & 0 deletions app/models/service_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ def encryption_opts
def live?
active? && approved?
end

def redirect_uris
super.presence || Array(redirect_uri)
end
end
7 changes: 4 additions & 3 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class Session
vendor_session_id
].freeze

def initialize(user_session, current_user)
def initialize(user_session:, current_user:, issuer:)
@user_session = user_session
@current_user = current_user
@issuer = issuer
@user_session[:idv] ||= new_idv_session
end

Expand Down Expand Up @@ -82,7 +83,7 @@ def create_usps_entry
self.pii = Pii::Attributes.new_from_json(user_session[:decrypted_pii])
end

UspsConfirmationMaker.new(pii: pii).perform
UspsConfirmationMaker.new(pii: pii, issuer: issuer).perform
end

def alive?
Expand All @@ -95,7 +96,7 @@ def address_mechanism_chosen?

private

attr_accessor :user_session, :current_user
attr_accessor :user_session, :current_user, :issuer

def new_idv_session
{ params: {}, step_attempts: { financials: 0, phone: 0 } }
Expand Down
4 changes: 1 addition & 3 deletions app/services/idv/vendor_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def agent_error_resolution(err_msg)
Proofer::Resolution.new(
success: false,
errors: { agent: [err_msg] },
vendor_resp: Proofer::Vendor::MockResponse.new(
reasons: [err_msg]
)
vendor_resp: OpenStruct.new(reasons: [err_msg])
)
end
end
Expand Down
Loading

0 comments on commit 0b972c9

Please sign in to comment.