Implemented basic auth

ref #26
This commit is contained in:
2021-02-13 16:09:58 +01:00
parent e306cdb2c8
commit bdeadd274b
4 changed files with 40 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
import { Action } from "routing-controllers";
import { config } from '../config';
/**
* Handles authentication via jwt's (Bearer authorization header) for all api endpoints using the @Authorized decorator.
* @param action Routing-Controllers action object that provides request and response objects among other stuff.
* @param permissions The permissions that the endpoint using @Authorized requires.
*/
const AuthChecker = async (action: Action) => {
const provided_token = action.request.query.key;
return provided_token == config.api_key;
}
export default AuthChecker