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

fix(security): do not commit aws-exports.js file #69

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
AWS_REGION=
AMPLIFY_IDENTITYPOOL_ID=
AMPLIFY_USERPOOL_ID=
AMPLIFY_WEBCLIENT_ID=
ORY_SDK_URL=
ORY_SDK_TOKEN=
CEDULA_API=
Expand All @@ -9,4 +13,4 @@ ENCRYPTION_KEY=
RECAPTHA_API_KEY=
RECAPTHA_PROJECT_ID=
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=
NEXT_PUBLIC_GOOGLE_ANALYTICS=
NEXT_PUBLIC_GOOGLE_ANALYTICS=
4 changes: 4 additions & 0 deletions .github/workflows/cloudrun-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:
service: ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}-${{ needs.versioning.outputs.version || env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
region: ${{ inputs.region }}
env_vars: |
AWS_REGION=${{ vars.AWS_REGION }},
AMPLIFY_IDENTITYPOOL_ID=${{ vars.AMPLIFY_IDENTITYPOOL_ID }},
AMPLIFY_USERPOOL_ID=${{ vars.AMPLIFY_USERPOOL_ID }},
AMPLIFY_WEBCLIENT_ID=${{ secrets.AMPLIFY_WEBCLIENT_ID }},
ORY_SDK_URL=${{ secrets.ORY_SDK_URL }},
ORY_SDK_TOKEN=${{ secrets.ORY_SDK_TOKEN }},
CEDULA_API=${{ secrets.CEDULA_API }},
Expand Down
24 changes: 0 additions & 24 deletions src/aws-exports.js

This file was deleted.

8 changes: 2 additions & 6 deletions src/helpers/rekognition.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { Amplify, withSSRContext } from 'aws-amplify';
import { Rekognition } from '@aws-sdk/client-rekognition';
import { withSSRContext } from 'aws-amplify';
import { NextApiRequest } from 'next/types';

import awsExports from '../aws-exports';

Amplify.configure({ ...awsExports, ssr: true });

export async function getRekognitionClient(
req: NextApiRequest
): Promise<Rekognition> {
const SSR = withSSRContext({ req });
const credentials = await SSR.Credentials.get();

const rekognitionClient = new Rekognition({
region: awsExports.aws_project_region,
region: process.env.AWS_REGION,
credentials,
});

Expand Down
11 changes: 9 additions & 2 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ import TagManager from 'react-gtm-module';

import { SnackbarProvider } from '../components/elements/alert';
import Layout from '../components/layout';
import awsExports from '../aws-exports';
import { theme } from '../themes';

import '../../public/fonts/poppins_wght.css';
import '@aws-amplify/ui-react/styles.css';
import '@/styles/globals.css';

Amplify.configure(awsExports);
const awsConfig = {
aws_project_region: process.env.AWS_REGION,
aws_cognito_identity_pool_id: process.env.AMPLIFY_IDENTITYPOOL_ID,
aws_cognito_region: process.env.AWS_REGION, // This could also be a separate environment variable if needed
aws_user_pools_id: process.env.AMPLIFY_USERPOOL_ID,
aws_user_pools_web_client_id: process.env.AMPLIFY_WEBCLIENT_ID,
};

Amplify.configure(awsConfig);

export default function App({ Component, pageProps }: AppProps) {
// Google Tag Manager
Expand Down
Loading