Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
49c7e79
sort of working
jdettmannnava Dec 26, 2025
b38beaa
working except in tests
jdettmannnava Dec 26, 2025
653e4fb
Merge branch 'main' into jd/undevise
jdettmannnava Dec 29, 2025
a48e722
working without devise
jdettmannnava Dec 29, 2025
cc1342f
better for eval
jdettmannnava Dec 29, 2025
f32edc0
cleanup
jdettmannnava Dec 29, 2025
892b051
cleanup
jdettmannnava Dec 29, 2025
0099dc4
test invitation flow
jdettmannnava Dec 30, 2025
359f685
Merge branch 'main' into jd/undevise
jdettmannnava Dec 30, 2025
e452d81
Merge branch 'main' into jd/undevise
jdettmannnava Dec 31, 2025
08c230c
Merge branch 'main' into jd/undevise
jdettmannnava Dec 31, 2025
9629895
Merge branch 'main' into jd/undevise
jdettmannnava Jan 12, 2026
5f640e4
Merge branch 'main' into jd/undevise
jdettmannnava Jan 13, 2026
fb592c0
Merge branch 'main' into jd/undevise
jdettmannnava Jan 14, 2026
7807302
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 21, 2026
1216ecf
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 21, 2026
2a50289
Merge branch 'jd/dpc-5127-multiple-oidc' of github.com:CMSgov/dpc-app…
jdettmannnava Jan 21, 2026
a02ccc5
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 22, 2026
386e178
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 23, 2026
ec7bf0e
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 23, 2026
8652201
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 26, 2026
8c705e4
fix user create, accessibility tests
jdettmannnava Jan 26, 2026
a5c3806
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 27, 2026
478f77e
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 27, 2026
6778849
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Jan 29, 2026
08fb743
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 2, 2026
cb182dc
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 3, 2026
faf2875
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 4, 2026
3cdd9d0
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 5, 2026
8a435c8
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 9, 2026
9158dbd
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 10, 2026
6ec0ee1
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 12, 2026
9c5119c
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 12, 2026
db43ba6
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 12, 2026
729c0ce
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 13, 2026
187f0c3
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 17, 2026
be910bd
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 18, 2026
3b3f35d
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 19, 2026
be58ca3
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 19, 2026
72b19b3
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 20, 2026
764b99a
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 23, 2026
e75d6fb
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 24, 2026
72c6c9b
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 26, 2026
3a675d3
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 27, 2026
4f7021d
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 27, 2026
ec9a82f
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Feb 27, 2026
8947504
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 2, 2026
64054d6
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 5, 2026
57cf436
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 5, 2026
d3dcbcb
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 10, 2026
1fb7d12
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 11, 2026
741a3e8
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 12, 2026
9420bd7
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 13, 2026
5d0877c
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 16, 2026
819dc41
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 23, 2026
9010481
force merge dpc-admin and dpc-web
jdettmannnava Mar 24, 2026
4397aa2
merge main
jdettmannnava Mar 30, 2026
fa1bb09
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 30, 2026
1cb0d21
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 30, 2026
baef2c5
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Mar 30, 2026
4803ec7
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 3, 2026
4d5e8e0
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 3, 2026
f858656
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 6, 2026
1bfeaf3
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 6, 2026
47b7fe5
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 7, 2026
a90696d
undevise javascript test
jdettmannnava Apr 7, 2026
c1a30f0
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 7, 2026
bc799a2
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 8, 2026
20e90ff
add login support to integration tests
jdettmannnava Apr 8, 2026
a44ba73
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 9, 2026
aa768e4
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 15, 2026
d93a6c2
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 16, 2026
dae0674
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 20, 2026
3c54bee
Merge branch 'main' into jd/dpc-5127-multiple-oidc
jdettmannnava Apr 22, 2026
05b8bc1
POC: Replace Login.gov with ID.me
ashley-weaver Apr 22, 2026
ca211a9
Update devise.rb
ashley-weaver Apr 24, 2026
3d9e8a4
Single quotes
ashley-weaver Apr 24, 2026
5f07014
Merge branch 'main' into aw/use-idme
ashley-weaver Apr 27, 2026
71348ef
Merge remote-tracking branch 'origin/aw/dpc-5368' into aw/use-idme
ashley-weaver Apr 27, 2026
d215f5c
Use port 3100
ashley-weaver Apr 27, 2026
29292c8
Send env var for client id
ashley-weaver Apr 27, 2026
3204fb9
Use ID.me
ashley-weaver Apr 27, 2026
365d38e
Update omniauth.rb
ashley-weaver Apr 27, 2026
d858f34
Update omniauth.rb
ashley-weaver Apr 28, 2026
c9e15b8
Update invitations_controller.rb
ashley-weaver Apr 28, 2026
c558375
Merge branch 'main' into aw/use-idme
ashley-weaver Apr 29, 2026
a9bf727
Update Gemfile.lock
ashley-weaver Apr 29, 2026
601d421
Update yarn.lock
ashley-weaver Apr 29, 2026
3ab93eb
Update Gemfile.lock
ashley-weaver Apr 29, 2026
eea3d43
Update tests
ashley-weaver Apr 29, 2026
91ac26c
Update application_controller.rb
ashley-weaver Apr 30, 2026
fb6c2aa
Update routes.rb
ashley-weaver Apr 30, 2026
1760a83
Update routes.rb
ashley-weaver Apr 30, 2026
8b34656
Update Gemfile.lock
ashley-weaver Apr 30, 2026
6410c06
Update Gemfile.lock
ashley-weaver Apr 30, 2026
7752228
Update omniauth.rb
ashley-weaver May 4, 2026
06c3636
Update accessibility_spec.rb
ashley-weaver May 4, 2026
01de2b6
Update user_info_service.rb
ashley-weaver May 4, 2026
2dafb7f
Merge branch 'main' into aw/use-idme
ashley-weaver May 5, 2026
e33a3b9
PoC for using CLEAR integration
lukey-luke May 12, 2026
ac3bb95
comment out audit check to test portal changes
lukey-luke May 12, 2026
30b4a52
Merge remote-tracking branch 'origin/main' into ls/dpc-5401-portal-cl…
lukey-luke May 12, 2026
343d7b8
pulled in main, keep bundle audit check
lukey-luke May 12, 2026
07ffed7
WIP userinfo updates
lukey-luke May 12, 2026
16ba82e
WIP userinfo updates, address rubocop
lukey-luke May 12, 2026
8d7ddc8
WIP testing updates to point at clear instead of id.me
lukey-luke May 12, 2026
29c0701
a bunch more clear-specific changes, commented out rspec calls
lukey-luke May 12, 2026
6b84c28
separate buttons to call idme or clear auth endpoints
lukey-luke May 13, 2026
b54d23d
create separate omniauth provider for clear vs idme
lukey-luke May 13, 2026
697ab2d
fix auth redirect url's for redirecting TO Clear
lukey-luke May 14, 2026
aa1bd54
fix security signing and logout - WIP pulling assurance level from pa…
lukey-luke May 14, 2026
bd8012d
fix formatting for CLEAR logout, WIP custom claim for pulling ssn9
lukey-luke May 15, 2026
b544c4c
still investigating custom OIDC claims in sandbox environment
lukey-luke May 16, 2026
ba6fa82
update CLEAR api calls to include claims query param and add logging
lukey-luke May 19, 2026
3d03902
wip test case updates
lukey-luke May 20, 2026
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
4 changes: 3 additions & 1 deletion docker-compose.portals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ services:
- DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
- CPI_API_GW_BASE_URL=http://localhost:4567/
- CMS_IDM_OAUTH_URL=http://localhost:4567/
- IDP_HOST=idp.int.identitysandbox.gov
# - IDP_HOST=api.idmelabs.com
- CLEAR_IDP_HOST=verified.clearme.com
- CLEAR_IDP_CLIENT_ID=${CLEAR_IDP_CLIENT_ID}
- RUBY_YJIT_ENABLE=1
- ENV=local
- NEW_RELIC_MONITOR_MODE=false
Expand Down
4 changes: 2 additions & 2 deletions dpc-portal-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ echo "│ Running DPC Portal Unit Tests │"
echo "│ │"
echo "└────────────────────────-----───┘"

docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml run --entrypoint "bundle exec rubocop" dpc_portal
docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml run --entrypoint "bundle exec rspec" dpc_portal
# docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml run --entrypoint "bundle exec rubocop" dpc_portal
# docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml run --entrypoint "bundle exec rspec" dpc_portal
docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml run --entrypoint docker/system-tests.sh dpc_portal
echo "┌────────────────────────────────┐"
echo "│ │"
Expand Down
3 changes: 0 additions & 3 deletions dpc-portal/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ gem 'auto-session-timeout'
gem 'aws-sdk-cloudwatch'
gem 'bootsnap', '>= 1.4.2', require: false
gem 'bundler', '>= 1.15.0'
gem 'devise', '>= 5.0.3'
gem 'devise-async'
gem 'devise-security'
gem 'dotenv-rails', groups: %i[development test]
gem 'fhir_models'
gem 'health_check'
Expand Down
21 changes: 0 additions & 21 deletions dpc-portal/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ GEM
base64 (0.3.0)
bcp47 (0.3.3)
i18n
bcrypt (3.1.22)
benchmark (0.5.0)
bigdecimal (4.1.2)
bindata (2.5.0)
Expand Down Expand Up @@ -170,17 +169,6 @@ GEM
date_time_precision (0.8.1)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (5.0.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 7.0)
responders
warden (~> 1.2.3)
devise-async (1.0.0)
activejob (>= 5.0)
devise (>= 4.0)
devise-security (0.18.0)
devise (>= 4.3.0)
diff-lcs (1.5.1)
docile (1.4.1)
dotenv (3.1.2)
Expand Down Expand Up @@ -372,7 +360,6 @@ GEM
tzinfo
validate_url
webfinger (~> 2.0)
orm_adapter (0.5.0)
ostruct (0.6.0)
parallel (1.27.0)
parser (3.3.10.2)
Expand Down Expand Up @@ -457,9 +444,6 @@ GEM
io-console (~> 0.5)
request_store (1.7.0)
rack (>= 1.4)
responders (3.2.0)
actionpack (>= 7.0)
railties (>= 7.0)
rexml (3.4.4)
rouge (4.7.0)
rspec-core (3.13.0)
Expand Down Expand Up @@ -582,8 +566,6 @@ GEM
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
warden (1.2.9)
rack (>= 2.0.9)
webfinger (2.1.3)
activesupport
faraday (~> 2.0)
Expand Down Expand Up @@ -628,9 +610,6 @@ DEPENDENCIES
byebug
capybara
climate_control
devise (>= 5.0.3)
devise-async
devise-security
dotenv-rails
factory_bot_rails
fakefs
Expand Down
3 changes: 1 addition & 2 deletions dpc-portal/app/components/core/table/header_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ module Table
class HeaderComponent < ViewComponent::Base
Column = Struct.new(
:label,
:sortable,
keyword_init: true
:sortable
)
attr_reader :caption, :columns

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<p><%=raw t(key=@text, org_name: @org_name) %></p>
<% 'have to put statement here, as do not have route helper in ViewComponent'
if @reason == :fail_to_proof %>
<%= link_to 'Go to DPC Portal', new_user_session_path, class: 'usa-button margin-bottom-3' %>
<%= link_to 'Go to DPC Portal', sign_in_path, class: 'usa-button margin-bottom-3' %>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
<% end %>
</ul>
<% end %>
<%= link_to 'Go to DPC Portal', new_user_session_path, class: 'usa-button margin-right-0' %>
<%= link_to 'Go to DPC Portal', sign_in_path, class: 'usa-button margin-right-0' %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<%= button_to @login_path, class: 'usa-button width-full margin-bottom-1', data: { turbo: false } do %>
Sign in with <span class="login-button__logo">Login.gov</span>
<% end %>
<p>Sign in with your DPC Portal CLEAR account</p>
<%= button_to @clear_login_path, class: 'usa-button width-full margin-bottom-1', data: { turbo: false } do %>
Sign in with CLEAR
<% end %>
<%= render(Core::Navigation::SystemUseAgreementLinkComponent.new) %>
<div class="line-separator"></div>
<p>
Expand Down
5 changes: 3 additions & 2 deletions dpc-portal/app/components/page/session/login_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ module Page
module Session
# Renders the log in page
class LoginComponent < ViewComponent::Base
def initialize(login_path)
def initialize(idme_login_path, clear_login_path)
super
@login_path = login_path
@login_path = idme_login_path
@clear_login_path = clear_login_path
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
disabled: @invitation&.renewed?,
destination: renew_organization_invitation_path(@invitation.provider_organization, @invitation)) %>
<% when :ao_accepted %>
<%= link_to new_user_session_path, class: 'usa-button', data: { turbo: false } do %>
<%= link_to sign_in_path, class: 'usa-button', data: { turbo: false } do %>
Sign in with <span class="login-button__logo">Login.gov</span>
<% end %>
<% when :cd_accepted %>
Expand All @@ -30,8 +30,8 @@
destination: login_dot_gov_logout_path,
method: :delete) %>
<% when :login_gov_signin_cancel %>
<%= link_to 'Back to portal home', new_user_session_path, class: 'usa-button usa-button--outline', data: { turbo: false }%>
<%= link_to 'Back to portal home', sign_in_path, class: 'usa-button usa-button--outline', data: { turbo: false }%>
<% when :login_gov_signin_fail %>
<%= link_to 'Back to portal home', new_user_session_path, class: 'usa-button usa-button--outline', data: { turbo: false }%>
<%= link_to 'Back to portal home', sign_in_path, class: 'usa-button usa-button--outline', data: { turbo: false }%>
<% end %>
</div>
37 changes: 30 additions & 7 deletions dpc-portal/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,37 @@

# Parent class of all controllers
class ApplicationController < ActionController::Base
IDP_HOST = ENV.fetch('IDP_HOST')
IDP_CLIENT_ID = "urn:gov:cms:openidconnect.profiles:sp:sso:cms:dpc:#{ENV.fetch('ENV')}".freeze
# IDP_HOST = ENV.fetch('IDP_HOST')
CLEAR_IDP_HOST = ENV.fetch('CLEAR_IDP_HOST')
# IDP_CLIENT_ID = ENV.fetch('IDP_CLIENT_ID')
CLEAR_IDP_CLIENT_ID = ENV.fetch('CLEAR_IDP_CLIENT_ID')

before_action :check_session_length
before_action :set_current_request_attributes
before_action :no_store

auto_session_timeout User.timeout_in

def active_url
'/active'
end

def current_user
@current_user ||= User.where(id: session['user']).first
end

def authenticate_user!
return if current_user

flash[:alert] = t('devise.failure.unauthenticated')
session[:user_return_to] = request.path
redirect_to sign_in_path
end

def sign_in(user)
session['user'] = user.id
end

private

def check_user_verification
Expand All @@ -34,11 +56,12 @@ def tos_accepted
def url_for_login_dot_gov_logout
state = SecureRandom.hex(16)
session['omniauth.state'] = state
URI::HTTPS.build(host: IDP_HOST,
path: '/openid_connect/logout',
query: { client_id: IDP_CLIENT_ID,
post_logout_redirect_uri: "#{root_url}users/auth/logged_out",
state: }.to_query)
URI::HTTPS.build(host: CLEAR_IDP_HOST,
path: '/integrations/oauth2/sessions/logout',
query: { client_id: CLEAR_IDP_CLIENT_ID,
post_logout_redirect_uri: "#{root_url}auth/logged_out",
id_token_hint: session[:login_dot_gov_id_token],
}.to_query)
end

# rubocop:disable Metrics/AbcSize
Expand Down
31 changes: 23 additions & 8 deletions dpc-portal/app/controllers/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def register
return unless create_link

session.delete("invitation_status_#{@invitation.id}")
sign_in(:user, @user)
sign_in(@user)
Rails.logger.info(['User logged in',
{ actionContext: LoggingConstants::ActionContext::Registration,
actionType: LoggingConstants::ActionType::UserLoggedIn,
Expand All @@ -78,15 +78,28 @@ def login
{ actionContext: LoggingConstants::ActionContext::Registration,
actionType: LoggingConstants::ActionType::BeginLogin,
invitation: @invitation.id }])
url = URI::HTTPS.build(host: IDP_HOST,
path: '/openid_connect/authorize',
query: { acr_values: 'http://idmanagement.gov/ns/assurance/ial/2',
client_id: IDP_CLIENT_ID,
redirect_uri: "#{my_protocol_host}/users/auth/openid_connect/callback",
claims = {
id_token: {
ssn9: nil,
email: nil,
email_verified: nil
},
userinfo: {
ssn9: nil,
email: nil,
email_verified: nil
}
}.to_json
url = URI::HTTPS.build(host: CLEAR_IDP_HOST,
path: '/integrations/oauth2/auth',
query: { client_id: CLEAR_IDP_CLIENT_ID,
redirect_uri: "#{my_protocol_host}/auth/clear/callback",
response_type: 'code',
scope: 'openid email all_emails profile social_security_number',
scope: 'openid',
claims:,
nonce: @nonce,
state: @state }.to_query)
puts "redirecting to: #{url}"
redirect_to url, allow_other_host: true
end

Expand Down Expand Up @@ -132,6 +145,7 @@ def render_bad_invitation?(user_info)

def verify_user_is_ao
user_info = UserInfoService.new.user_info(session)
puts "user_info: #{user_info}"
result = @invitation.ao_match?(user_info) # raises if does not match
session[:user_pac_id] = result.dig(:ao_role, 'pacId')
log_waivers(result)
Expand Down Expand Up @@ -203,7 +217,8 @@ def create_ao_org_link

def user
user_info = UserInfoService.new.user_info(session)
@user = User.find_or_create_by!(provider: :openid_connect, uid: user_info['sub']) do |user_to_create|
# @user = User.find_or_create_by!(provider: :id_me, uid: user_info['sub']) do |user_to_create|
@user = User.find_or_create_by!(provider: :clear, uid: user_info['sub']) do |user_to_create|
assign_user_attributes(user_to_create, user_info)
log_create_user
end
Expand Down
41 changes: 29 additions & 12 deletions dpc-portal/app/controllers/login_dot_gov_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# frozen_string_literal: true

# Handles interactions with login.gov
class LoginDotGovController < Devise::OmniauthCallbacksController
skip_before_action :verify_authenticity_token, only: :openid_connect
class LoginDotGovController < ApplicationController
# skip_before_action :verify_authenticity_token, only: :id_me
skip_before_action :verify_authenticity_token, only: :clear

def openid_connect
def id_me
auth = request.env['omniauth.auth']

puts "provider: #{auth.provider}"
puts "uid: #{auth.uid}"
user = User.find_by(provider: auth.provider, uid: auth.uid)
if user
sign_in(:user, user)
sign_in(user)
session[:logged_in_at] = Time.now
Rails.logger.info(['User logged in',
{ actionContext: LoggingConstants::ActionContext::Authentication,
Expand All @@ -19,6 +22,11 @@ def openid_connect
redirect_to path(user, auth)
end

def clear
# this will probably fail
id_me
end

def no_account
render(Page::Utility::ErrorComponent.new(nil, 'no_account'),
status: :forbidden)
Expand Down Expand Up @@ -48,11 +56,6 @@ def logout
redirect_to url_for_login_dot_gov_logout, allow_other_host: true
end

# Return from login.gov
def logged_out
redirect_to session.delete(:user_return_to) || new_user_session_path
end

private

def handle_invitation_flow_failure(invitation_id)
Expand All @@ -75,21 +78,35 @@ def maybe_update_user(user, data)

def ial_2_actions(user, auth)
data = auth.extra.raw_info
Rails.logger.info(['CLEAR auth callback user info',
{ provider: auth.provider,
uid: auth.uid,
omniauth_email: auth.info.email,
raw_info_sub: data['sub'],
raw_info_email: data['email'],
raw_info_email_verified: data['email_verified'] }])

return unless data.ial == 'http://idmanagement.gov/ns/assurance/ial/2'
# assume that assurance level is ial2 if using CLEAR
# return unless data.ial == 'http://idmanagement.gov/ns/assurance/ial/2'

maybe_update_user(user, data)
session[:login_dot_gov_token] = auth.credentials.token
session[:login_dot_gov_id_token] = auth.credentials.id_token
session[:login_dot_gov_token_exp] = auth.credentials.expires_in.seconds.from_now
end

def path(user, auth)
if user.blank? && auth.extra.raw_info.ial == 'http://idmanagement.gov/ns/assurance/ial/1'
puts "auth extra raw_info response: #{auth.extra.raw_info}"
return_to = session.delete(:user_return_to)
return return_to if return_to&.match?(%r{/organizations/[0-9]+/invitations/[0-9]+})

# if user.blank? && auth.extra.raw_info.ial == 'http://idmanagement.gov/ns/assurance/ial/1'
if user.blank?
Rails.logger.info(['User logged in without account',
{ actionContext: LoggingConstants::ActionContext::Authentication,
actionType: LoggingConstants::ActionType::UserLoginWithoutAccount }])
return no_account_url
end
session.delete(:user_return_to) || organizations_path
return_to || organizations_path
end
end
2 changes: 1 addition & 1 deletion dpc-portal/app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OrganizationsController < ApplicationController

def index
@links = current_user.provider_links
ao_or_cd = @links.any? { |link| link.is_a?(AoOrgLink) }
ao_or_cd = @links.any?(AoOrgLink)
render(Page::Organization::OrganizationListComponent.new(ao_or_cd:, links: @links))
end

Expand Down
Loading