Skip to content

Commit

Permalink
okay, i think I managed to get the local authentication working again…
Browse files Browse the repository at this point in the history
… (in dev server). gonna start trying to see if I can get the actual github actions workflow to do it too.
  • Loading branch information
siddheshraze committed Sep 5, 2024
1 parent d6bc405 commit 5097bf4
Show file tree
Hide file tree
Showing 12 changed files with 490 additions and 1,832 deletions.
32 changes: 3 additions & 29 deletions .github/workflows/main-forestgeo-livesite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
echo AZURE_AD_CLIENT_ID=${{ secrets.AZURE_AD_CLIENT_ID }} >> frontend/.env
echo AZURE_AD_TENANT_ID=${{ secrets.AZURE_AD_TENANT_ID }} >> frontend/.env
echo NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} >> frontend/.env
echo NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} >> frontend/.env
echo NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL_DEV }} >> frontend/.env
echo AZURE_SQL_USER=${{ secrets.AZURE_SQL_USER }} >> frontend/.env
echo AZURE_SQL_PASSWORD=${{ secrets.AZURE_SQL_PASSWORD }} >> frontend/.env
echo AZURE_SQL_SERVER=${{ secrets.AZURE_SQL_SERVER }} >> frontend/.env
Expand Down Expand Up @@ -122,32 +122,6 @@ jobs:
echo OWNER=${{ secrets.OWNER }} >> frontend/.env
echo REPO=${{ secrets.REPO }} >> frontend/.env
- name: create env file (in frontend/ directory) -- development
id: create-env-file-dev
if: startsWith(github.ref, 'refs/heads/forestgeo-app-')
run: |
touch frontend/.env
echo AZURE_AD_CLIENT_SECRET=${{ secrets.AZURE_AD_CLIENT_SECRET }} >> frontend/.env
echo AZURE_AD_CLIENT_ID=${{ secrets.AZURE_AD_CLIENT_ID }} >> frontend/.env
echo AZURE_AD_TENANT_ID=${{ secrets.AZURE_AD_TENANT_ID }} >> frontend/.env
echo NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} >> frontend/.env
echo NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} >> frontend/.env
echo AZURE_SQL_USER=${{ secrets.AZURE_SQL_USER }} >> frontend/.env
echo AZURE_SQL_PASSWORD=${{ secrets.AZURE_SQL_PASSWORD }} >> frontend/.env
echo AZURE_SQL_SERVER=${{ secrets.AZURE_SQL_SERVER }} >> frontend/.env
echo AZURE_SQL_DATABASE=${{ secrets.AZURE_SQL_DATABASE }} >> frontend/.env
echo AZURE_SQL_PORT=${{ secrets.AZURE_SQL_PORT }} >> frontend/.env
echo AZURE_STORAGE_SAS_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_SAS_CONNECTION_STRING }} >> frontend/.env
echo AZURE_SQL_SCHEMA=${{ secrets.AZURE_SQL_SCHEMA }} >> frontend/.env
echo AZURE_SQL_CATALOG_SCHEMA=${{ secrets.AZURE_SQL_CATALOG_SCHEMA }} >> frontend/.env
echo AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} >> frontend/.env
echo NEXTAUTH_DEBUG=true >> frontend/.env
echo NODE_ENV=development >> frontend/.env
echo PORT=3000 >> frontend/.env
echo FG_PAT=${{ secrets.FG_PAT }} >> frontend/.env
echo OWNER=${{ secrets.OWNER }} >> frontend/.env
echo REPO=${{ secrets.REPO }} >> frontend/.env
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -203,7 +177,7 @@ jobs:
app-name: 'forestgeo-livesite'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_PRODUCTION }}
package: ./frontend/build/standalone
package: frontend/build/standalone

deploy-app-development:
needs: build-app-development
Expand All @@ -225,4 +199,4 @@ jobs:
app-name: 'forestgeo-livesite'
slot-name: 'development'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_DEVELOPMENT }}
package: ./frontend/build/standalone
package: frontend/build/standalone
6 changes: 4 additions & 2 deletions frontend/app/api/auth/[[...nextauth]]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { UserAuthRoles } from '@/config/macros';
import { SitesRDS } from '@/config/sqlrdsdefinitions/zones';

const handler = NextAuth({
secret: process.env.NEXTAUTH_SECRET as string,
secret: process.env.NEXTAUTH_SECRET!,
providers: [
AzureADProvider({
clientId: process.env.AZURE_AD_CLIENT_ID!,
clientSecret: process.env.AZURE_AD_CLIENT_SECRET!,
tenantId: process.env.AZURE_AD_CLIENT_ID!,
tenantId: process.env.AZURE_AD_TENANT_ID!,
authorization: { params: { scope: 'openid profile email user.Read' } }
})
],
Expand All @@ -20,6 +20,8 @@ const handler = NextAuth({
},
callbacks: {
async signIn({ user, account, profile, email: signInEmail, credentials }) {
console.log('callback -- signin');
console.log('process envs: ', process.env);
const azureProfile = profile as AzureADProfile;
const userEmail = user.email || signInEmail || azureProfile.preferred_username;
if (typeof userEmail !== 'string') {
Expand Down
26 changes: 0 additions & 26 deletions frontend/app/api/hash/census/route.ts

This file was deleted.

28 changes: 0 additions & 28 deletions frontend/app/api/hash/plots/route.ts

This file was deleted.

24 changes: 0 additions & 24 deletions frontend/app/api/hash/quadrats/route.ts

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/config/crypto-actions.ts

This file was deleted.

1 change: 0 additions & 1 deletion frontend/config/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'reflect-metadata';
import { PoolConnection } from 'mysql2/promise';
import { runQuery } from '@/components/processors/processormacros';

Expand Down
16 changes: 12 additions & 4 deletions frontend/ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ module.exports = {
name: 'forestgeo-livesite',
script: './node_modules/next/dist/bin/next',
args: 'start -p ' + (process.env.PORT || 3000),
watch: false,
autorestart: true
watch: true,
autorestart: true,
env: {
NODE_ENV: 'production',
PORT: 3000
}
},
{
name: 'forestgeo-livesite-development',
script: './node_modules/next/dist/bin/next',
args: 'start -p ' + (process.env.PORT || 3000),
watch: false,
autorestart: true
watch: true,
autorestart: true,
env: {
NODE_END: 'development',
PORT: 3000
}
}
]
};
4 changes: 2 additions & 2 deletions frontend/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Redirects authenticated users to the dashboard page from the home page.
* Allows the request to continue if no redirect conditions are met.
*/

import { getToken } from 'next-auth/jwt';
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { NextRequest, NextResponse } from 'next/server';

export async function middleware(request: NextRequest) {
const session = await getToken({
Expand Down
2 changes: 0 additions & 2 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const nextConfig = withBundleAnalyzer({
unoptimized: true // since images are served from public directory
},
env: {
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
AZURE_SQL_USER: process.env.AZURE_SQL_USER,
AZURE_SQL_PASSWORD: process.env.AZURE_SQL_PASSWORD,
AZURE_SQL_SERVER: process.env.AZURE_SQL_SERVER,
Expand Down
Loading

0 comments on commit 5097bf4

Please sign in to comment.