-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mocked_auth ERB files * 53352 - moves mocked_users controller to credential; fix templating + routes + credential/service * updates authorize callback to include state + encoded_credential * updates mocked_auth routes.rb; adds JS to credential#index * updates verbage in template; fixes formatting in mock_auth/lib/credential/service * updates specs for lib/credential/service_spec.rb * changes mock_auth view to only show credential_payload * adds validate_credential_list_params check + updates validate_index_params * adds credential#index spec; adds resuce error json; fixes linting issue * fix linting of rescue json vs html * fix linting issue 2nd * [53015] Updating mocked auth credential specs --------- Co-authored-by: Trevor Bosaw <[email protected]>
- Loading branch information
Showing
8 changed files
with
291 additions
and
4 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
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
4 changes: 4 additions & 0 deletions
4
modules/mocked_authentication/app/views/layouts/application.html.erb
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<%= yield %> | ||
</html> |
188 changes: 188 additions & 0 deletions
188
modules/mocked_authentication/app/views/mocked_authentication/credential/index.html.erb
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,188 @@ | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta name="robots" content="none" /> | ||
<title>VA.gov | Mocked Authentication</title> | ||
<link | ||
href="https://unpkg.com/@department-of-veterans-affairs/formation/dist/formation.min.css" | ||
rel="stylesheet" | ||
crossorigin="anonymous" | ||
/> | ||
</head> | ||
<style> | ||
body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; } | ||
main { flex: 1 } | ||
.content div:first-of-type > h2 { margin-top: 0; } | ||
.container { margin: 0 auto; padding: 60px 16px; } | ||
|
||
.code-block { | ||
font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", | ||
"Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", | ||
"Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, | ||
monospace; | ||
background: #d9d9d9; | ||
overflow-y: scroll; | ||
max-height: 600px; | ||
} | ||
|
||
pre { | ||
white-space: pre-wrap; | ||
overflow-x: auto; | ||
tab-size: 4; | ||
} | ||
|
||
code { | ||
overflow-wrap: break-word; | ||
display: block; | ||
color: #333; | ||
padding: 0 2em; | ||
margin: -24px 0; | ||
} | ||
|
||
header { | ||
position: absolute; | ||
width: 100%; | ||
top: 0; left: 0; | ||
text-align: center; | ||
} | ||
|
||
.header-container { | ||
min-height: 85px; | ||
padding-top: 1em; | ||
background: #112e51; | ||
color: #fff; | ||
} | ||
|
||
footer { | ||
height: 2.5rem; | ||
width: 100%; | ||
bottom: 0; | ||
text-align: center; | ||
} | ||
|
||
@media screen and (min-width: 1600px) { | ||
main { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.container { | ||
margin: 6em auto 0; | ||
max-width: 1400px; | ||
display: grid; | ||
grid-template-columns: 600px 700px; | ||
grid-template-rows: 1fr; | ||
} | ||
} | ||
</style> | ||
<body> | ||
<noscript> | ||
<p> | ||
Your browser does not support JavaScript or you do not have JavaScript | ||
enabled. Please press the Continue button once to proceed with sign-in. | ||
</p> | ||
</noscript> | ||
<header> | ||
<div class="header-container"> | ||
<h1>Mocked Authentication</h1> | ||
</div> | ||
</header> | ||
<main> | ||
<div class="container"> | ||
<section class="content"> | ||
<div> | ||
<h2>Select a profile to continue</h2> | ||
<p> | ||
Select a mock user profile from the dropdown below to continue with the mocked authentication flow. <em>(*Available only in the local and development environments)</em> | ||
</p> | ||
<form> | ||
<label for="profiles"> | ||
<select id="profiles_select"> | ||
<option value="">Select a profile</option> | ||
<% @mock_profiles.each do |profile_name, profile| %> | ||
<option value="<%= profile[:encoded_credential] %>"> | ||
<%= profile[:credential_payload]['email'] %> | ||
</option> | ||
<% end %> | ||
</select> | ||
</label> | ||
<button id="authorize">Continue signing in</button> | ||
</form> | ||
</div> | ||
<div> | ||
<h2>Mock user profile not what you expected?</h2> | ||
<p> | ||
Use the instructions found in the | ||
<a | ||
href="https://github.com/department-of-veterans-affairs/vets-api-mockdata" | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
> | ||
vets-api-mockdata repo</a> to create and/or update a mocked user. | ||
</p> | ||
</div> | ||
<div> | ||
<h2>What is Mocked Authentication?</h2> | ||
<p> | ||
Read through our | ||
<a | ||
href="https://github.com/department-of-veterans-affairs/vets-api-mockdata" | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
>documentation</a | ||
> | ||
to find more information on how to use Mocked Authentication. | ||
</p> | ||
</div> | ||
</section> | ||
<div class="code-block"> | ||
<pre> | ||
<code id="selected_profile"></code> | ||
</pre> | ||
</div> | ||
</div> | ||
</main> | ||
<footer> | ||
Need help? Reach out in the | ||
<a | ||
href="slack://app.slack.com/client/T03FECE8V/CSFV4QTKN" | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
> | ||
#vsp-identity Slack | ||
</a> | ||
channel. | ||
</footer> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const profileSelectDropdown = document.getElementById('profiles_select') | ||
const selectedProfileCode = document.getElementById('selected_profile'); | ||
const authorizeBtn = document.getElementById('authorize'); | ||
const profiles = <%= raw(@mock_profiles.to_json) %>; | ||
const currentUri = new URL(window.location); | ||
let currentlySelected = {}; | ||
|
||
if(!currentUri.searchParams.has('state') || !Object.keys(currentlySelected).length) { | ||
const copyOfCurrentlySelected = | ||
selectedProfileCode.innerText = JSON.stringify(currentlySelected.credential_payload || {}, null, 2); | ||
authorizeBtn.disabled = true; | ||
} | ||
|
||
profileSelectDropdown | ||
.addEventListener('change', e => { | ||
currentlySelected = Object.values(profiles).find(({ encoded_credential }) => encoded_credential === e.target.value) || {} | ||
selectedProfileCode.innerText = JSON.stringify(currentlySelected.credential_payload ?? {}, null, 2); | ||
authorizeBtn.disabled = !Object.keys(currentlySelected).length ? true : false; | ||
}) | ||
|
||
authorizeBtn | ||
.addEventListener('click', e => { | ||
e.preventDefault(); | ||
const url = `authorize/?state=<%= @state %>&credential_info=${currentlySelected.encoded_credential}` | ||
window.location = url; | ||
}) | ||
}) | ||
</script> | ||
</body> |
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