Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creates arp sign-in button #33802

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import PropTypes from 'prop-types';
import { createOAuthRequest } from 'platform/utilities/oauth/utilities';
import { SERVICE_PROVIDERS } from 'platform/user/authentication/constants';

export default function ARFSignInButton({ csp }) {
if (!csp) return null;
const { image } = SERVICE_PROVIDERS[csp];

const onClick = async e => {
e.preventDefault();

const url = await createOAuthRequest({
application: 'arp',
clientId: 'vaweb',
type: csp,
});

window.location = url;
};

return (
<button

Check warning on line 23 in src/applications/accredited-representative-portal/components/common/SignInButton.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/accredited-representative-portal/components/common/SignInButton.jsx:23:5:The <va-button> Web Component should be used instead of the button HTML element.

Check warning on line 23 in src/applications/accredited-representative-portal/components/common/SignInButton.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/accredited-representative-portal/components/common/SignInButton.jsx:23:5:The <va-button> Web Component should be used instead of the button HTML element.
type="button"
className={`arf usa-button ${csp}-button`}
onClick={onClick}
>
Sign in with {image}
</button>
);
}

ARFSignInButton.propTypes = {
application: PropTypes.string,
csp: PropTypes.string,
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { VaLoadingIndicator } from '@department-of-veterans-affairs/component-li

import { selectUserProfile, selectIsUserLoading } from '../selectors/user';
import { SIGN_IN_URL } from '../constants';
// uncomment when ready to enable
// import SignInButton from '../components/common/SignInButton';
import LandingPageWelcome from '../components/LandingPageWelcome/LandingPageWelcome';

const LandingPage = () => {
Expand Down Expand Up @@ -44,6 +46,7 @@ const LandingPage = () => {
>
Sign in or create account
</a>
{/* <SignInButton csp="logingov" /> */}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
&__look-and-feel {
background: linear-gradient(
to left,
var(--vads-color-primary-alt)10%,
var(--vads-color-primary-alt) 10%,
var(--vads-color-primary-alt-dark) 40%,
var(--vads-color-primary-alt-darkest)
);
Expand Down Expand Up @@ -69,3 +69,40 @@
font-weight: 700;
}
}

/* used for login button styling consitencies */
button.arf {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
max-width: 330px;
padding: 0.75em;
font-size: 16px;
margin: 1em 0;
white-space: normal !important;

&.idme-button {
background: var(--vads-color-success-dark);

&:hover {
background: var(
--vads-button-color-background-primary-alt-active-on-light
);
}
}

&.logingov-button {
background: var(--vads-color-secondary);

&:hover {
background: var(--vads-color-secondary-darkest);
}
}

img,
svg {
height: 1em;
padding: 0 0.25em;
}
}
2 changes: 2 additions & 0 deletions src/platform/utilities/oauth/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const COOKIES = {
};

export const OAUTH_KEYS = {
APPLICATION: 'application',
CLIENT_ID: 'client_id',
CODE_CHALLENGE: 'code_challenge',
CODE_CHALLENGE_METHOD: 'code_challenge_method',
Expand Down Expand Up @@ -77,6 +78,7 @@ export const AUTHORIZE_KEYS_WEB = generateOAuthKeysWithout([
'CODE_VERIFIER',
'CODE',
'REDIRECT_URI',
'APPLICATION',
]);

export const AUTHORIZE_KEYS_MOBILE = generateOAuthKeysWithout([
Expand Down
1 change: 1 addition & 0 deletions src/platform/utilities/oauth/utilities.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable camelcase */
import environment from 'platform/utilities/environment';
import recordEvent from 'platform/monitoring/record-event';
import { teardownProfileSession } from 'platform/user/profile/utilities';

Check warning on line 4 in src/platform/utilities/oauth/utilities.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/platform/utilities/oauth/utilities.js:4:1:Dependency cycle detected.

Check warning on line 4 in src/platform/utilities/oauth/utilities.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/platform/utilities/oauth/utilities.js:4:1:Dependency cycle detected.
import { updateLoggedInStatus } from 'platform/user/authentication/actions';
import {
AUTH_EVENTS,
Expand Down Expand Up @@ -134,6 +134,7 @@
const usedClientId = clientId || oAuthOptions.clientId;
// Build the authorization URL query params from config
const oAuthParams = {
...(application && { [OAUTH_KEYS.APPLICATION]: application }),
[OAUTH_KEYS.CLIENT_ID]: encodeURIComponent(usedClientId),
[OAUTH_KEYS.ACR]: usedAcr,
[OAUTH_KEYS.RESPONSE_TYPE]: OAUTH_ALLOWED_PARAMS.CODE,
Expand Down
Loading