Skip to content

Commit

Permalink
LG-835 Add LOA3 to Open ID Connect Sinatra Test App (#47)
Browse files Browse the repository at this point in the history
* LG-835 Add LOA3 to Open ID Connect Sinatra Test App
  • Loading branch information
stevegsa authored Jan 28, 2019
1 parent 06389e1 commit b16cea7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OpenidConnectRelyingParty < Sinatra::Base

get '/' do
if openid_configuration
erb :index, locals: { authorization_url: authorization_url }
erb :index, locals: { loa1_url: authorization_url(1), loa3_url: authorization_url(3) }
else
erb :errors, locals: { error: openid_configuration_error }
end
Expand All @@ -47,11 +47,11 @@ class OpenidConnectRelyingParty < Sinatra::Base

private

def authorization_url
def authorization_url(loa)
openid_configuration[:authorization_endpoint] + '?' + {
client_id: CLIENT_ID,
response_type: 'code',
acr_values: ENV['ACR_VALUES'],
acr_values: 'http://idmanagement.gov/ns/assurance/loa/' + loa.to_s,
scope: 'openid email',
redirect_uri: File.join(REDIRECT_URI, '/auth/result'),
state: random_value,
Expand Down
20 changes: 16 additions & 4 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
<div class="container py2">
<h1> Login.gov Open ID Connect Sinatra</h1>
<div class="mb1 right-align">
<a href="<%= authorization_url %>" class="btn btn-outline bg-white navy">
<img class="align-middle" width="125" src="/images/login-gov.svg" alt="Login gov">
</a>
<div class="mb1">
<label for="loa_1">
<input type="radio" name="loa" id="loa_1" value="1" checked="checked"> LOA1
</label>
<label for="loa_3">
<input type="radio" name="loa" id="loa_3" value="3"> LOA3
</label>
</div>
<a onclick='gotoAuthUrl(); return false;' href="<%= loa1_url %>" class="btn btn-outline bg-white navy">
<img class="align-middle" width="125" src="/images/login-gov.svg" alt="Login gov">
</a>
</div>
<%= erb :page_content %>
</div>

<script>
function gotoAuthUrl() {
window.location.href = document.getElementById('loa_1').checked ? "<%= loa1_url %>" : "<%= loa3_url %>";
}
</script>

0 comments on commit b16cea7

Please sign in to comment.