Skip to content

Commit

Permalink
chore: release (#165)
Browse files Browse the repository at this point in the history
* feat: update wiki link (#160)

* chore: links

update wiki links

* chore: wiki url

change url ot include query string

* feat: logout idle (#161)

* feat: logout idle

logout idle users

* chore: cleanup

remove console log

* fix: timer reset (#162)

stop idle timer resetting on session refresh

* chore: logout modal (#163)

logout user when dismissing modal

* feat: upgraded git actions to be compatible with node 20 (#164)

* feat: set BCEID_WEB_SERVICE_URL env var

---------

Co-authored-by: Jonathan Langlois <[email protected]>
  • Loading branch information
NithinKuruba and jlangy authored May 27, 2024
1 parent 6fffcdc commit ca9d1a0
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 43 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -55,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -68,4 +68,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
10 changes: 5 additions & 5 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
pre-commit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install asdf
uses: asdf-vm/actions/setup@v1
uses: asdf-vm/actions/setup@v3
- name: Cache tools
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
/home/runner/.asdf
Expand All @@ -29,7 +29,7 @@ jobs:
commitlint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v2
- uses: wagoid/commitlint-github-action@v5
14 changes: 7 additions & 7 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: hmarr/debug-action@v2
- uses: actions/checkout@v2
- uses: hmarr/debug-action@v3
- uses: actions/checkout@v4

- name: Log in to the GitHub Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v5
with:
images: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}

Expand All @@ -54,17 +54,17 @@ jobs:
echo "release_tag=${{ endsWith(github.ref, '/main') && steps.release.outputs.tag_name || steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v5
with:
context: app
push: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-metabase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
contents: read

steps:
- uses: hmarr/debug-action@v2
- uses: actions/checkout@v2
- uses: hmarr/debug-action@v3
- uses: actions/checkout@v4

- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
unit-test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
Expand Down
11 changes: 9 additions & 2 deletions app/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ export default function GlobalModal({ setModalConfig, modalConfig }: Props) {
const { showCancelButton, showConfirmButton, onConfirm } = modalConfig;
const hasButtons = showCancelButton || showConfirmButton;

const closeModal = () => {
if (modalConfig.onClose) {
modalConfig.onClose();
}
clearModal();
};

const onConfirmClick = async () => {
if (!onConfirm) return;
setWaiting(true);
Expand All @@ -99,14 +106,14 @@ export default function GlobalModal({ setModalConfig, modalConfig }: Props) {

return (
<Modal>
<div className="background" onClick={clearModal} />
<div className="background" onClick={closeModal} />
<div className="content">
<div className="header">
<div>
<FontAwesomeIcon icon={faCheckCircle} size="lg" />
<span className="header-text">{modalConfig.title}</span>
</div>
<FontAwesomeIcon icon={faClose} className="exit" size="lg" onClick={clearModal} />
<FontAwesomeIcon icon={faClose} className="exit" size="lg" onClick={closeModal} />
</div>
<div className="body">
{modalConfig.body}
Expand Down
1 change: 1 addition & 0 deletions app/context/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface ModalConfig {
body: string;
showConfirmButton?: boolean;
showCancelButton?: boolean;
onClose?: () => void;
onConfirm?: () => Promise<void>;
}

Expand Down
53 changes: 45 additions & 8 deletions app/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import styled from 'styled-components';
import BCSans from './BCSans';
import Navigation from './Navigation';
import BottomAlertProvider from './BottomAlert';
import { getSession, useSession } from 'next-auth/react';
import { useEffect } from 'react';
import { useSession } from 'next-auth/react';
import { useEffect, useContext } from 'react';
import { User } from 'next-auth';
import { wikiURL } from 'utils/helpers';
import { formatWikiURL } from 'utils/helpers';
import { useIdleTimer } from 'react-idle-timer';
import { ModalContext } from 'context/modal';

const headerPlusFooterHeight = '152px';

Expand Down Expand Up @@ -150,23 +152,32 @@ const RightMenuItems = () => (
</a>
</HoverItem>
<HoverItem>
<a href={wikiURL} target="_blank" title="Documentation" rel="noreferrer">
<a href={formatWikiURL()} target="_blank" title="Documentation" rel="noreferrer">
<FontAwesomeIcon size="2x" icon={faFileAlt} />
</a>
</HoverItem>
</>
);

const modalContent = {
title: `Session Expiring`,
body: `Your session will expire soon and you will be signed out automatically. Do you want to stay signed in?`,
showCancelButton: false,
showConfirmButton: true,
};

// identity_provider, idir_userid, client_roles, family_name, given_name
function Layout({ children, onLoginClick, onLogoutClick }: any) {
const router = useRouter();
const session = useSession();
const currentUser: Partial<User> = session?.data?.user!;
const pathname = router.pathname;
const { setModalConfig } = useContext(ModalContext);

const checkSession = async () => {
if (Date.now() > session?.data?.accessTokenExpiry) {
const session = await getSession();
if (session?.error === 'RefreshAccessTokenError') {
if (Date.now() > session?.data?.accessTokenExpiry * 1000) {
const updatedSession = await session.update();
if (updatedSession?.error === 'RefreshAccessTokenError') {
onLogoutClick();
}
}
Expand All @@ -179,6 +190,32 @@ function Layout({ children, onLoginClick, onLogoutClick }: any) {
}
});

useIdleTimer({
onPrompt: (_event, timer) => {
setModalConfig({
...modalContent,
show: true,
onConfirm: async () => {
await session.update();
timer?.reset();
},
onClose: () => {
onLogoutClick();
},
});
},
onIdle: () => {
setModalConfig({
...modalContent,
show: false,
});
onLogoutClick();
},
timeout: 30 * 60 * 1000,
promptBeforeIdle: 5 * 60 * 1000,
disabled: !['authenticated', 'loading'].includes(session?.status),
});

const rightSide = currentUser ? (
<LoggedUser>
<div className="welcome">Welcome {`${currentUser?.given_name} ${currentUser?.family_name}`}</div>
Expand Down Expand Up @@ -207,7 +244,7 @@ function Layout({ children, onLoginClick, onLogoutClick }: any) {
<FontAwesomeIcon size="2x" icon={faEnvelope} />
</a>
&nbsp;&nbsp;
<a href={wikiURL} target="_blank" title="Wiki" rel="noreferrer">
<a href={formatWikiURL()} target="_blank" title="Wiki" rel="noreferrer">
<FontAwesomeIcon size="2x" icon={faFileAlt} />
</a>
</li>
Expand Down
1 change: 1 addition & 0 deletions app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = {
ches_password: process.env.CHES_PASSWORD,

bceid_service_id: process.env.BCEID_SERVICE_ID,
bceid_web_service_url: process.env.BCEID_WEB_SERVICE_URL || '',
bceid_service_basic_auth: process.env.BCEID_SERVICE_BASIC_AUTH,
idir_jwks_uri: process.env.IDIR_JWKS_URI,
idir_issuer: process.env.IDIR_ISSUER,
Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"react-bootstrap": "^2.4.0",
"react-dom": "18.1.0",
"react-hook-form": "^7.31.3",
"react-idle-timer": "^5.7.2",
"react-loader-spinner": "^6.0.0-0",
"react-select": "^5.8.0",
"react-typography": "^0.16.20",
Expand Down
5 changes: 2 additions & 3 deletions app/pages/api/bceid-service/bceid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import get from 'lodash.get';
import { getIdirUserGuid } from 'utils/jwt';

const { serverRuntimeConfig = {} } = getConfig() || {};
const { bceid_service_id, bceid_service_basic_auth } = serverRuntimeConfig;
const { bceid_service_id, bceid_service_basic_auth, bceid_web_service_url } = serverRuntimeConfig;

const parseStringSync = promisify(parseString);

const serviceUrl = 'https://gws2.test.bceid.ca/webservices/client/V10/BCeIDService.asmx?WSDL';
const defaultHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
authorization: `Basic ${bceid_service_basic_auth}`,
Expand Down Expand Up @@ -52,7 +51,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
const idirUserGuid = await getIdirUserGuid(token);
const xml = generateXML(property, accountType, matchKey, idirUserGuid);
const { response }: any = await soapRequest({
url: serviceUrl,
url: bceid_web_service_url,
headers: defaultHeaders,
xml,
timeout: 10000,
Expand Down
10 changes: 5 additions & 5 deletions app/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ResponsiveContainer, { MediaRule } from 'components/ResponsiveContainer';
import IntroRealms from 'svg/IntroRealms';
import { signIn, useSession } from 'next-auth/react';
import NextLink from 'next/link';
import { wikiURL } from 'utils/helpers';
import { formatWikiURL } from 'utils/helpers';

const JumbotronH1 = styled.h1`
font-size: 2.5rem;
Expand Down Expand Up @@ -113,10 +113,10 @@ const Home = () => {
<p className="large-font">Do you want to request a new Custom Realm?</p>
<p>
Over 90% of our clients benefit from our Standard Service, please visit our{' '}
<Link href={wikiURL}>information</Link> to ensure this is not a fit for you. To maintain our{' '}
<Link href={`${wikiURL}/Alerts-and-Us#service-levels`}>service levels</Link>, we need to evaluate
every single custom realm request coming to us. Please fill out the form to start the conversation
with us.
<Link href={formatWikiURL()}>information</Link> to ensure this is not a fit for you. To maintain our{' '}
<Link href={formatWikiURL('Alerts-and-Us#service-levels')}>service levels</Link>, we need to
evaluate every single custom realm request coming to us. Please fill out the form to start the
conversation with us.
</p>
<strong className="custom-realm-link">
<NextLink href="/custom-realm-form">Request a Custom Realm</NextLink>
Expand Down
5 changes: 4 additions & 1 deletion app/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import getConfig from 'next/config';
const { serverRuntimeConfig = {} } = getConfig() || {};
const { dev_kc_url, test_kc_url, prod_kc_url } = serverRuntimeConfig;

export const wikiURL = 'https://mvp.developer.gov.bc.ca/docs/default/component/css-docs';
export const formatWikiURL = (page?: string) =>
`https://mvp.developer.gov.bc.ca/docs/default/component/css-docs/${
page ?? ''
}?utm_source=sso-wiki&utm_medium=web&utm_campaign=retirement-notice-sso`;

export enum RoleEnum {
ADMIN = 'admin',
Expand Down
5 changes: 2 additions & 3 deletions app/utils/idir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import get from 'lodash.get';
import map from 'lodash.map';

const { serverRuntimeConfig = {} } = getConfig() || {};
const { bceid_service_id, bceid_service_basic_auth } = serverRuntimeConfig;
const { bceid_service_id, bceid_service_basic_auth, bceid_web_service_url } = serverRuntimeConfig;

export const parseStringSync = promisify(parseString);

export const serviceUrl = 'https://gws2.test.bceid.ca/webservices/client/V10/BCeIDService.asmx?WSDL';
export const defaultHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
authorization: `Basic ${bceid_service_basic_auth}`,
Expand Down Expand Up @@ -101,7 +100,7 @@ export function parseAccount(data: any) {

export const makeSoapRequest = async (xmlPayload: string) => {
return await soapRequest({
url: serviceUrl,
url: bceid_web_service_url,
headers: defaultHeaders,
xml: xmlPayload,
timeout: 10000,
Expand Down
4 changes: 2 additions & 2 deletions app/utils/mailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getConfig from 'next/config';
import { Session } from 'next-auth';
import { RealmProfile } from 'types/realm-profile';
import { Roster } from '@prisma/client';
import { generateRealmLinksByEnv, generateMasterRealmLinksByEnv, wikiURL } from './helpers';
import { generateRealmLinksByEnv, generateMasterRealmLinksByEnv, formatWikiURL } from './helpers';

const { serverRuntimeConfig = {} } = getConfig() || {};
const { app_env, sso_logout_redirect_uri } = serverRuntimeConfig;
Expand Down Expand Up @@ -109,7 +109,7 @@ const emailFooter = `
stroke="#0e3468" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</g>
</svg>
<a href="${wikiURL}" style="padding-left: 4px; color: #0e3468;">Knowledge Base</a>
<a href="${formatWikiURL()}" style="padding-left: 4px; color: #0e3468;">Knowledge Base</a>
</div>
<div style="display: flex; align-items: center;">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
5 changes: 5 additions & 0 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6698,6 +6698,11 @@ react-hook-form@^7.31.3:
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.48.2.tgz#01150354d2be61412ff56a030b62a119283b9935"
integrity sha512-H0T2InFQb1hX7qKtDIZmvpU1Xfn/bdahWBN1fH19gSe4bBEqTfmlr7H3XWTaVtiK4/tpPaI1F3355GPMZYge+A==

react-idle-timer@^5.7.2:
version "5.7.2"
resolved "https://registry.yarnpkg.com/react-idle-timer/-/react-idle-timer-5.7.2.tgz#f506db28a86645dd1b87987116501703e512142b"
integrity sha512-+BaPfc7XEUU5JFkwZCx6fO1bLVK+RBlFH+iY4X34urvIzZiZINP6v2orePx3E6pAztJGE7t4DzvL7if2SL/0GQ==

react-is@^16.13.1, react-is@^16.3.2, react-is@^16.6.3, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
Expand Down
1 change: 1 addition & 0 deletions helm/webapp/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ spec:
{{`{{ with secret "`}}{{ .Values.vault.vaultSecretEngine }}/{{ .Values.vault.realmRegistrySecret }}{{`" -}}
export BCEID_SERVICE_BASIC_AUTH="{{ .Data.data.BCEID_SERVICE_BASIC_AUTH }}"
export BCEID_SERVICE_ID="{{ .Data.data.BCEID_SERVICE_ID}}"
export BCEID_WEB_SERVICE_URL="{{ .Data.data.BCEID_WEB_SERVICE_URL}}"
export DEV_KC_USERNAME="{{ .Data.data.DEV_KC_USERNAME}}"
export DEV_KC_PASSWORD="{{ .Data.data.DEV_KC_PASSWORD}}"
export DEV_KC_URL="{{ .Data.data.DEV_KC_URL}}"
Expand Down

0 comments on commit ca9d1a0

Please sign in to comment.