Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/authentication #268

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cleaned up PR
  • Loading branch information
dutchie032 committed Sep 11, 2024
commit 3b7f738543c6104e20e93aeca9131c96234cf535
26 changes: 0 additions & 26 deletions lua/DCS-gRPC/grpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,6 @@ end
-- load and start RPC
--

function table_print(tt, indent, done)
done = done or {}
indent = indent or 0
if type(tt) == "table" then
local sb = {}
for key, value in pairs(tt) do
table.insert(sb, string.rep(" ", indent)) -- indent it
if type(value) == "table" and not done[value] then
done[value] = true
table.insert(sb, key .. " = {\n");
table.insert(sb, table_print(value, indent + 2, done))
table.insert(sb, string.rep(" ", indent)) -- indent it
table.insert(sb, "}\n");
elseif "number" == type(key) then
table.insert(sb, string.format("\"%s\"\n", tostring(value)))
else
table.insert(sb, string.format(
"%s = \"%s\"\n", tostring(key), tostring(value)))
end
end
return table.concat(sb)
else
return tt .. "\n"
end
end

if isMissionEnv then
assert(grpc.start({
version = GRPC.version,
Expand Down
2 changes: 1 addition & 1 deletion src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct AuthInterceptor {
#[async_trait]
impl RequestInterceptor for AuthInterceptor {
async fn intercept(&self, req: Request<Body>) -> Result<Request<Body>, Status> {
match req.headers().get("bearer").map(|v| v.to_str()) {
match req.headers().get("X-API-Key").map(|v| v.to_str()) {
Some(Ok(token)) => {
//check if token is correct if auth is enabled
if self.auth_config.enabled == false || token == self.auth_config.token {
Expand Down
Loading