Skip to content

Commit

Permalink
Addendum to last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kürzeder committed Jul 26, 2019
1 parent dc298b9 commit 4333606
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions module/CFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(lua_touserdata(lua_vm, 3)));
const auto algorithm = jwt_algorithm(reinterpret_cast<unsigned>(lua_touserdata(lua_vm, 3)));
const auto private_key_path = lua_tostring(lua_vm, 4);
std::string private_key = private_key_path;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion module/CFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions module/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*>(JWT_ALGORITHM_HS256));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS384", reinterpret_cast<void*>(JWT_ALGORITHM_HS384));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS512", reinterpret_cast<void*>(JWT_ALGORITHM_HS512));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS256", reinterpret_cast<void*>(JWT_ALGORITHM_RS256));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS384", reinterpret_cast<void*>(JWT_ALGORITHM_RS384));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS512", reinterpret_cast<void*>(JWT_ALGORITHM_RS512));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS256", reinterpret_cast<void*>(jwt_algorithm_hs256));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS384", reinterpret_cast<void*>(jwt_algorithm_hs384));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_HS512", reinterpret_cast<void*>(jwt_algorithm_hs512));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS256", reinterpret_cast<void*>(jwt_algorithm_rs256));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS384", reinterpret_cast<void*>(jwt_algorithm_rs384));
CFunctions::register_lua_global(lua_vm, "JWT_ALGORITHM_RS512", reinterpret_cast<void*>(jwt_algorithm_rs512));
}

MTAEXPORT bool DoPulse()
Expand Down
14 changes: 7 additions & 7 deletions module/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4333606

Please sign in to comment.