-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 26/eval-footer
- Loading branch information
Showing
28 changed files
with
598 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# local dev env vars for login.gov | ||
export LOGIN_CLIENT_ID=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:challenge_gov_portal_eval_dev | ||
export LOGIN_REDIRECT_EVAL_URL=http://localhost:3000/auth/result | ||
export LOGOUT_REDIRECT_EVAL_URL=http://localhost:3000/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ use nix | |
|
||
mkdir -p .nix-bundler | ||
export BUNDLE_PATH=./.nix-bundler | ||
|
||
# Login Env Vars | ||
source .env_login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationController < ActionController::Base | ||
helper_method :current_user, :logged_in? | ||
|
||
def current_user | ||
return unless session[:userinfo] | ||
|
||
user_token = session["userinfo"][0]["sub"] | ||
@current_user ||= User.find_by(token: user_token) if user_token | ||
end | ||
|
||
def logged_in? | ||
!!current_user | ||
end | ||
|
||
def sign_in(login_userinfo) | ||
user = User.user_from_userinfo(login_userinfo) | ||
|
||
@current_user = user | ||
session[:userinfo] = login_userinfo | ||
end | ||
|
||
def sign_out | ||
@current_user = nil | ||
session.delete(:userinfo) | ||
end | ||
|
||
def redirect_if_logged_in(path = "/dashboard") | ||
return unless logged_in? | ||
|
||
redirect_to path, notice: I18n.t("already_logged_in_notice") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class DashboardController < ApplicationController | ||
def index; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: security_log | ||
# | ||
# id :bigint not null, primary key | ||
# action :string(255) not null | ||
# details :jsonb | ||
# originator_id :bigint | ||
# originator_role :string(255) | ||
# originator_identifier :string(255) | ||
# target_id :integer | ||
# target_type :string(255) | ||
# target_identifier :string(255) | ||
# logged_at :datetime not null | ||
# originator_remote_ip :string(255) | ||
# | ||
class SecurityLog < ApplicationRecord | ||
self.table_name = 'security_log' | ||
|
||
belongs_to :originator, class_name: 'User', optional: true | ||
|
||
ROLES = %w[ | ||
status_change account_update role_change accessed_site session_duration | ||
create read update delete submit renewal_request | ||
].freeze | ||
|
||
validates :action, presence: true, inclusion: { in: ROLES } | ||
validates :logged_at, presence: true | ||
|
||
before_validation :set_logged_at, on: :create | ||
|
||
# Attributes | ||
attribute :action, :string | ||
attribute :details, :jsonb | ||
attribute :originator_id, :integer | ||
attribute :originator_role, :string | ||
attribute :originator_identifier, :string | ||
attribute :originator_remote_ip, :string | ||
attribute :target_id, :integer | ||
attribute :target_type, :string | ||
attribute :target_identifier, :string | ||
attribute :logged_at, :datetime | ||
|
||
def self.timestamp_attributes_for_create | ||
super + %w[logged_at] | ||
end | ||
|
||
private | ||
|
||
def set_logged_at | ||
self.logged_at ||= DateTime.now | ||
end | ||
end |
Oops, something went wrong.