diff --git a/module/CFunctions.cpp b/module/CFunctions.cpp index 7ebee08..5700e87 100644 --- a/module/CFunctions.cpp +++ b/module/CFunctions.cpp @@ -29,7 +29,7 @@ int CFunctions::sign_jwt_token(lua_State* lua_vm) // Read other arguments const auto claims = Utils::parse_named_table(lua_vm, 2); - const auto algorithm = jwt_algorithm(reinterpret_cast(lua_touserdata(lua_vm, 3))); + const auto algorithm = jwt_algorithm(reinterpret_cast(lua_touserdata(lua_vm, 3))); const auto private_key_path = lua_tostring(lua_vm, 4); std::string private_key = private_key_path; @@ -58,17 +58,17 @@ int CFunctions::sign_jwt_token(lua_State* lua_vm) switch(algorithm) { - case JWT_ALGORITHM_HS256: + case jwt_algorithm_hs256: return jwt.sign(jwt::algorithm::hs256{ private_key }); - case JWT_ALGORITHM_HS384: + case jwt_algorithm_hs384: return jwt.sign(jwt::algorithm::hs384{ private_key }); - case JWT_ALGORITHM_HS512: + case jwt_algorithm_hs512: return jwt.sign(jwt::algorithm::hs512{ private_key }); - case JWT_ALGORITHM_RS256: + case jwt_algorithm_rs256: return jwt.sign(jwt::algorithm::rs256{ std::string(), private_key }); - case JWT_ALGORITHM_RS384: + case jwt_algorithm_rs384: return jwt.sign(jwt::algorithm::rs384{ std::string(), private_key }); - case JWT_ALGORITHM_RS512: + case jwt_algorithm_rs512: return jwt.sign(jwt::algorithm::rs512{ std::string(), private_key }); default: break; diff --git a/module/CFunctions.h b/module/CFunctions.h index 8892303..d7defd5 100644 --- a/module/CFunctions.h +++ b/module/CFunctions.h @@ -16,7 +16,7 @@ class CFunctions return 1; } - static inline void register_lua_global( lua_State* lua_vm, const char* name, void* value ) + static inline void register_lua_global(lua_State* lua_vm, const char* name, void* value) { lua_pushlightuserdata(lua_vm, value); lua_setglobal(lua_vm, name); diff --git a/module/Main.cpp b/module/Main.cpp index b7ea794..38752bb 100644 --- a/module/Main.cpp +++ b/module/Main.cpp @@ -51,12 +51,12 @@ MTAEXPORT void RegisterFunctions(lua_State* lua_vm) pModuleManager->RegisterFunction(lua_vm, "jwtGetClaims", &CFunctions::get_jwt_claims); // Register globals - CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS256", reinterpret_cast(JWT_ALGORITHM_HS256)); - CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS384", reinterpret_cast(JWT_ALGORITHM_HS384)); - CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS512", reinterpret_cast(JWT_ALGORITHM_HS512)); - CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS256", reinterpret_cast(JWT_ALGORITHM_RS256)); - CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS384", reinterpret_cast(JWT_ALGORITHM_RS384)); - CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS512", reinterpret_cast(JWT_ALGORITHM_RS512)); + CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS256", reinterpret_cast(jwt_algorithm_hs256)); + CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS384", reinterpret_cast(jwt_algorithm_hs384)); + CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS512", reinterpret_cast(jwt_algorithm_hs512)); + CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS256", reinterpret_cast(jwt_algorithm_rs256)); + CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS384", reinterpret_cast(jwt_algorithm_rs384)); + CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS512", reinterpret_cast(jwt_algorithm_rs512)); } MTAEXPORT bool DoPulse() diff --git a/module/Utils.h b/module/Utils.h index 40d773c..dbe7d02 100644 --- a/module/Utils.h +++ b/module/Utils.h @@ -14,14 +14,14 @@ static const int index_key = -2; #define DEBUG_LOG( msg ) #endif -enum jwt_algorithm +enum jwt_algorithm : unsigned { - JWT_ALGORITHM_HS256 = 0b1000000 << 0, - JWT_ALGORITHM_HS384 = 0b1000000 << 1, - JWT_ALGORITHM_HS512 = 0b1000000 << 2, - JWT_ALGORITHM_RS256 = 0b1000000 << 3, - JWT_ALGORITHM_RS384 = 0b1000000 << 4, - JWT_ALGORITHM_RS512 = 0b1000000 << 5 + jwt_algorithm_hs256 = 0b1000000 << 0, + jwt_algorithm_hs384 = 0b1000000 << 1, + jwt_algorithm_hs512 = 0b1000000 << 2, + jwt_algorithm_rs256 = 0b1000000 << 3, + jwt_algorithm_rs384 = 0b1000000 << 4, + jwt_algorithm_rs512 = 0b1000000 << 5 }; class Utils