-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added API Token Verification to lock restricted calls (#182)
* Added ability to set and clear token headers from front end * Added bearer token checking to restricted API calls - Protein upload, delete, and edit. * Linting pass * fix: print -> log.warn for consistency --------- Co-authored-by: xnought <bertuccd@oregonstate.edu>
- Loading branch information
1 parent
96e679e
commit 93ea05d
Showing
6 changed files
with
49 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
export * from "./openapi"; | ||
export { DefaultService as Backend } from "./openapi"; | ||
import { OpenAPI } from "./openapi"; | ||
import Cookies from "js-cookie"; | ||
|
||
export const BACKEND_URL = "http://localhost:8000"; | ||
OpenAPI.BASE = BACKEND_URL; | ||
|
||
// Sets the token header to the stored authentication token from the cookie | ||
export function setToken() { | ||
console.log("Setting Token") | ||
OpenAPI.TOKEN = Cookies.get("auth") | ||
} | ||
|
||
// Sets the token header to nothing. | ||
export function clearToken() { | ||
console.log("Clearing token.") | ||
OpenAPI.TOKEN = undefined | ||
} |
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