Skip to content

Commit

Permalink
add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
choden-dev committed Mar 10, 2024
1 parent cc20b34 commit 8a0715b
Show file tree
Hide file tree
Showing 16 changed files with 420 additions and 132 deletions.
80 changes: 60 additions & 20 deletions client/src/models/__generated__/schema.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 123 additions & 14 deletions common/__generated__/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 26 additions & 9 deletions server/src/business-layer/security/Authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,41 @@ export function expressAuthentication(
reject(new Error("No token provided"))
}

const token = authHeader.split(" ")[2] // Gets part after Bearer
const token = authHeader.split(" ")[1] // Gets part after Bearer

auth
.verifyIdToken(token)
.then((decodedToken) => {
const { uid } = decodedToken
auth.getUser(uid).then((user) => {
for (const scope of scopes!) {
if (!user.customClaims[scope]) {
throw new Error("No scope")
auth
.getUser(uid)
.then((user) => {
for (const scope of scopes!) {
if (user.customClaims === undefined) {
throw new FireBaseError(
"Authentication Error",
401,
"No Scope"
)
}
if (!(scope in user.customClaims)) {
throw new FireBaseError(
"Authentication Error",
401,
"No Scope"
)
}
}
}
resolve(user)
})
resolve(user)
})
.catch((reason) => {
console.error(reason)
reject(new FireBaseError("Authentication Error", 401, reason))
})
})
.catch((reason) => {
console.error(reason)
throw new FireBaseError("Authentication Error", 401, reason)
reject(new FireBaseError("Authentication Error", 401, reason))
})
})
}
Expand Down
2 changes: 0 additions & 2 deletions server/src/business-layer/security/Firebase.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
EMULATOR_AUTH_PORT,
EMULATOR_FIRESTORE_PORT,
EMULATOR_HOST
} from "data-layer/adapters/EmulatorConfig"
import * as _admin from "firebase-admin"

if (process.env.DEV || process.env.JEST_WORKER_ID !== undefined) {
process.env.FIRESTORE_EMULATOR_HOST = `${EMULATOR_HOST}:${EMULATOR_FIRESTORE_PORT}`
process.env.FIREBASE_AUTH_EMULATOR_HOST = `${EMULATOR_HOST}:${EMULATOR_AUTH_PORT}`
}

const firebase = _admin.initializeApp()
Expand Down
1 change: 0 additions & 1 deletion server/src/data-layer/adapters/EmulatorConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export const EMULATOR_PROJECT_ID = "uasc-ceebc"
export const EMULATOR_HOST = "localhost"
export const EMULATOR_FIRESTORE_PORT = 8080
export const EMULATOR_AUTH_PORT = 9090
8 changes: 0 additions & 8 deletions server/src/data-layer/adapters/FirestoreConfig.ts

This file was deleted.

Loading

0 comments on commit 8a0715b

Please sign in to comment.