Skip to content

Commit

Permalink
Merge branch 'development' into authjs
Browse files Browse the repository at this point in the history
  • Loading branch information
rhit-windsors committed Nov 14, 2024
2 parents d9be795 + fcc6872 commit 190ea82
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 50 deletions.
12 changes: 1 addition & 11 deletions apps/backend/job-runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
spec:
containers:
- name: runner
image: gladospipeline/glados-runner:main
image: gladospipeline/glados-runner:development
imagePullPolicy: Always
command: []
env:
Expand All @@ -19,16 +19,6 @@ spec:
secretKeyRef:
name: secret-env
key: MONGODB_PORT
- name: SERVICE_ROLE_KEY
valueFrom:
secretKeyRef:
name: secret-env
key: SERVICE_ROLE_KEY
- name: FIREBASE_KEY
valueFrom:
secretKeyRef:
name: secret-env
key: FIREBASE_KEY
- name: MONGODB_USERNAME
valueFrom:
secretKeyRef:
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/app/components/auth/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const ProtectedRoute = ({ children }) => {
const router = useRouter();
useEffect(() => {
if (session.status != "loading" && !session.data?.user) {
console.log('User is not signed in; redirecting them to /signin');
router.push('/signin');
console.log('User is not signed in; redirecting them to landing page');
router.push('/');
}
}, [!session.data?.user, router, session.status]);

Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/app/components/auth/SignUpModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const SignUpModal = ({ afterSignUp }) => {
<a
href='#'
className='w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-500 hover:bg-gray-50'
onClick={() => signIn("google", { redirectTo: "/dashboard" })}
>
<span className='sr-only'>
Sign in with Google
Expand All @@ -54,7 +55,7 @@ export const SignUpModal = ({ afterSignUp }) => {
</a>
</div>

<div>
{/* <div>
<a
href='#'
className='w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-500 hover:bg-gray-50'
Expand All @@ -64,7 +65,7 @@ export const SignUpModal = ({ afterSignUp }) => {
</span>
<AiOutlineTwitter className='w-5 h-5' />
</a>
</div>
</div> */}

<div>
<a
Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/auth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { MongoDBAdapter } from "@auth/mongodb-adapter";
import NextAuth from "next-auth";
import GitHub from "next-auth/providers/github";
import Keycloak from "next-auth/providers/keycloak";
import Google from "next-auth/providers/google";
// import Keycloak from "next-auth/providers/keycloak";
import clientPromise from "./lib/mongodb"

export const { handlers, signIn, signOut, auth } = NextAuth({
adapter: MongoDBAdapter(clientPromise, {databaseName: 'gladosdb'}),
providers: [GitHub, Keycloak],
providers: [GitHub, Google], //Add Keycloak here to do local testing
callbacks: {
authorized: async ({ auth }) => {
// Logged in users are authenticated, otherwise redirect to login page
Expand Down
9 changes: 4 additions & 5 deletions apps/frontend/lib/mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { getEnvVar } from '../utils/env';

// Adapted from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb

// const MONGODB_PORT = getEnvVar('MONGODB_PORT');
// const USERNAME = getEnvVar('MONGODB_USERNAME');
// const PASSWORD = getEnvVar('MONGODB_PASSWORD');
const MONGODB_PORT = getEnvVar('MONGODB_PORT');
const USERNAME = getEnvVar('MONGODB_USERNAME');
const PASSWORD = getEnvVar('MONGODB_PASSWORD');

// const MONGODB_URI = `mongodb://${USERNAME}:${PASSWORD}@glados-service-mongodb:${MONGODB_PORT}`;
const MONGODB_URI = 'mongodb://root:password123@137.112.104.86:30000/?directConnection=true';
const MONGODB_URI = `mongodb://${USERNAME}:${PASSWORD}@glados-service-mongodb:${MONGODB_PORT}`;
const MONGODB_OPTIONS = {};

export const DB_NAME = 'gladosdb';
Expand Down
9 changes: 1 addition & 8 deletions apps/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import base64

import requests
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore, storage
from bson.binary import Binary

from modules.data.types import DocumentId, IncomingStartRequest
Expand All @@ -31,17 +28,13 @@
logging.error("Failed to import the 'magic' package, you're probably missing a system level dependency")
sys.exit(1)

ENV_FIREBASE_CREDENTIALS = "FIREBASE_KEY"
DB_COLLECTION_EXPERIMENTS = "Experiments"

# set up logger
configure_root_logger()
syslogger = logging.getLogger(SYSTEM_LOGGER)
explogger = logging.getLogger(EXPERIMENT_LOGGER)

firebaseCredentials = credentials.Certificate(json.loads(_get_env(ENV_FIREBASE_CREDENTIALS)))
firebaseApp = firebase_admin.initialize_app(firebaseCredentials)
firebaseDb = firestore.client()

syslogger.info("GLADOS Runner Started")

Expand Down Expand Up @@ -87,7 +80,7 @@ def run_batch(data: IncomingStartRequest):


except Exception as err: # pylint: disable=broad-exception-caught
explogger.error("Error retrieving experiment data from firebase, aborting")
explogger.error("Error retrieving experiment data from mongo, aborting")
explogger.exception(err)
close_experiment_run(exp_id)
return
Expand Down
10 changes: 0 additions & 10 deletions kubernetes_init/backend/deployment-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ spec:
secretKeyRef:
name: secret-env
key: MONGODB_PORT
- name: SERVICE_ROLE_KEY
valueFrom:
secretKeyRef:
name: secret-env
key: SERVICE_ROLE_KEY
- name: FIREBASE_KEY
valueFrom:
secretKeyRef:
name: secret-env
key: FIREBASE_KEY
- name: MONGODB_USERNAME
valueFrom:
secretKeyRef:
Expand Down
20 changes: 10 additions & 10 deletions kubernetes_init/frontend/deployment-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ spec:
secretKeyRef:
name: secret-env
key: MONGODB_PORT
- name: SERVICE_ROLE_KEY
valueFrom:
secretKeyRef:
name: secret-env
key: SERVICE_ROLE_KEY
- name: FIREBASE_KEY
valueFrom:
secretKeyRef:
name: secret-env
key: FIREBASE_KEY
- name: MONGODB_USERNAME
valueFrom:
secretKeyRef:
Expand All @@ -73,6 +63,16 @@ spec:
secretKeyRef:
name: secret-env
key: AUTH_GITHUB_SECRET
- name: AUTH_GOOGLE_ID
valueFrom:
secretKeyRef:
name: secret-env
key: AUTH_GOOGLE_ID
- name: AUTH_GOOGLE_SECRET
valueFrom:
secretKeyRef:
name: secret-env
key: AUTH_GOOGLE_SECRET
- name: AUTH_TRUST_HOST
valueFrom:
secretKeyRef:
Expand Down

0 comments on commit 190ea82

Please sign in to comment.