Skip to content

Commit

Permalink
removed references to feature flag (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
daliclovr authored Oct 17, 2023
1 parent f004280 commit b359aa4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
3 changes: 0 additions & 3 deletions src/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class Constants
public static readonly string? AWS_ACCESS_KEY_ID;
public static readonly string? AWS_SECRET_ACCESS_KEY;
public static readonly string API_TOKEN_SALT;
public static readonly bool GRPC_AUTH_FEATURE_FLAG;

// Crons & Jobs
public static readonly string MONITOR_WITHDRAWALS_CRON = "10 0/5 * * * ?";
Expand Down Expand Up @@ -166,8 +165,6 @@ static Constants()

API_TOKEN_SALT = Environment.GetEnvironmentVariable("API_TOKEN_SALT") ?? "H/fCx1+maAFMcdi6idIYEg==";

GRPC_AUTH_FEATURE_FLAG = Environment.GetEnvironmentVariable("GRPC_AUTH_FEATURE_FLAG") == "true";

// Crons & Jobs
MONITOR_WITHDRAWALS_CRON = Environment.GetEnvironmentVariable("MONITOR_WITHDRAWALS_CRON") ?? MONITOR_WITHDRAWALS_CRON;

Expand Down
1 change: 0 additions & 1 deletion src/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"COINGECKO_KEY": "TBD",
"HTTP1_LISTEN_PORT": "38080",
"API_TOKEN_SALT": "H/fCx1+maAFMcdi6idIYEg==",
"GRPC_AUTH_FEATURE_FLAG": "false"
}
}
}
Expand Down
23 changes: 10 additions & 13 deletions src/Rpc/GRPCAuthInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
ServerCallContext context,
UnaryServerMethod<TRequest, TResponse> continuation)
{

if (Constants.GRPC_AUTH_FEATURE_FLAG) {
var token = context.RequestHeaders.FirstOrDefault(x => x.Key == "auth-token")?.Value;
if (token == null)
{
throw new RpcException(new Status(StatusCode.Unauthenticated, "No token provided"));
}
var token = context.RequestHeaders.FirstOrDefault(x => x.Key == "auth-token")?.Value;
if (token == null)
{
throw new RpcException(new Status(StatusCode.Unauthenticated, "No token provided"));
}

var apiToken = await _apiTokenRepository.GetByToken(token);

if (apiToken?.IsBlocked ?? true)
{
throw new RpcException(new Status(StatusCode.Unauthenticated, "Invalid token"));
}
var apiToken = await _apiTokenRepository.GetByToken(token);

if (apiToken?.IsBlocked ?? true)
{
throw new RpcException(new Status(StatusCode.Unauthenticated, "Invalid token"));
}

return await continuation(request, context);
Expand Down

0 comments on commit b359aa4

Please sign in to comment.