-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* started imlementing universal search GARBAGE CODE ALERT WIP * split apart code into 2 components * added noresults * Made search page accessible thru search button * Zoom to mural upon click in search menu * fixed pr comments * got rid of unnecessary comment * fixed search card width * Close sidebar on mural select * started working on backend auth * token example * changed authentication to be middleware * added middleware to all the put/post routes * removed a log * removed token error handling from controller * removed token error handling from controller * added token to frontend calls * added eb script to download auth key off bucket
- Loading branch information
1 parent
1499391
commit c601365
Showing
14 changed files
with
10,530 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Resources: | ||
AWSEBAutoScalingGroup: | ||
Metadata: | ||
AWS::CloudFormation::Authentication: | ||
S3Auth: | ||
type: "s3" | ||
buckets: ["elasticbeanstalk-us-east-1-115630815585"] | ||
roleName: | ||
"Fn::GetOptionSetting": | ||
Namespace: "aws:autoscaling:launchconfiguration" | ||
OptionName: "IamInstanceProfile" | ||
DefaultValue: "aws-elasticbeanstalk-ec2-role" | ||
files: | ||
# Private key | ||
"/mu-auth-73f4d05ed60d.json": | ||
mode: "000400" | ||
owner: root | ||
group: root | ||
authentication: "S3Auth" | ||
source: https://elasticbeanstalk-us-east-1-115630815585.s3.amazonaws.com/privatekey/mu-auth-73f4d05ed60d.json |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { FBAuth } from "./FBAuth" | ||
import { TokenError } from "../controllers/customErrors/TokenError"; | ||
import { Request, Response } from "express"; | ||
|
||
/** | ||
* Middleware that can be added at route level to add firebase authentication to a controller | ||
* Expects a valid firebase jwt token in headers.authorization | ||
* @param req HTTP request | ||
* @param res HTTP response | ||
* @param next reference to controller function to be executed if auth passes | ||
*/ | ||
export const authMiddleware = async (req: Request, res: Response, next: any) => { | ||
try {if (req.headers.authorization) { | ||
await FBAuth.auth() | ||
.verifyIdToken(req.headers.authorization) | ||
.then((decodedToken) => { | ||
next() | ||
}) | ||
.catch((e) => { | ||
console.log(e); | ||
throw new TokenError("Invalid Token!"); | ||
}); | ||
} else { | ||
throw new TokenError("No Token!"); | ||
}} | ||
catch (e) { | ||
res.status(400).json({ error: "Unauthorized!" }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import admin from "firebase-admin"; | ||
|
||
export const FBAuth = admin.initializeApp({ | ||
credential: admin.credential.applicationDefault(), | ||
databaseURL: "gs://mu-auth.appspot.com", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export class TokenError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
this.name = "TokenError"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c601365
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: