-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protect create2 verification with an auth0 authentication (#1090)
* generalize auth0 authentication functions * support different environments via env * support in ui docker build and update env * auth0: in ui instead of refreshing the token every 25 seconds, refresh the token each new request * remove old token management * Improve UI * add tests for create2 auth0 authentication * auth0: add missing AUTH0_CLIENTID to dev and stable envs * solve linter error * auth0: fix for linter * forbidden error for apiCheckPermission * accept only salt when is convertible to BigNumber * handle bearer tokens in create2 routes * check the user's information to validate the user instead of relying on short living tokens * fix missing getAccessTokenSilently in useEffect's dependencies * add missing openid, profile scopes in auth0 in tests
- Loading branch information
1 parent
e4fbfd4
commit c1705ea
Showing
27 changed files
with
523 additions
and
187 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { StatusCodes } from "http-status-codes"; | ||
import { IResponseError } from "../interfaces"; | ||
|
||
export class ForbiddenError implements IResponseError { | ||
code: number; | ||
message: string; | ||
|
||
constructor(message?: string) { | ||
this.code = StatusCodes.FORBIDDEN; | ||
this.message = message || "Forbidden"; | ||
} | ||
} |
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,12 @@ | ||
import { StatusCodes } from "http-status-codes"; | ||
import { IResponseError } from "../interfaces"; | ||
|
||
export class UnauthorizedError implements IResponseError { | ||
code: number; | ||
message: string; | ||
|
||
constructor(message?: string) { | ||
this.code = StatusCodes.UNAUTHORIZED; | ||
this.message = message || "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
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
16 changes: 12 additions & 4 deletions
16
src/server/controllers/verification/create2/stateless/create2.stateless.routes.ts
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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import { Router } from "express"; | ||
import { verifyCreate2Handler } from "./create2.stateless.handlers"; | ||
import { authenticatedRequest } from "../../verification.common"; | ||
import { safeHandler } from "../../../controllers.common"; | ||
import { isAuth0EnabledUser, jwtCheck } from "../../verification.common"; | ||
import { | ||
// hasVerifyCreate2Permission, | ||
apiVerifyCreate2Limiter, | ||
} from "../create2.common"; | ||
|
||
const router: Router = Router(); | ||
|
||
router | ||
.route("/verify/create2") | ||
.post(authenticatedRequest, safeHandler(verifyCreate2Handler)); | ||
router.route("/verify/create2").post( | ||
jwtCheck, | ||
// hasVerifyCreate2Permission, | ||
isAuth0EnabledUser, | ||
apiVerifyCreate2Limiter, | ||
safeHandler(verifyCreate2Handler) | ||
); | ||
|
||
export default router; |
Oops, something went wrong.