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

removed references to feature flag for grpc auth #316

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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 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 @@ -117,7 +116,7 @@
// Connections
POSTGRES_CONNECTIONSTRING = Environment.GetEnvironmentVariable("POSTGRES_CONNECTIONSTRING") ?? POSTGRES_CONNECTIONSTRING;

NBXPLORER_URI = GetEnvironmentalVariableOrThrowIfNotTesting("NBXPLORER_URI");

Check warning on line 119 in src/Helpers/Constants.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Possible null reference assignment.

NBXPLORER_BTCRPCURL = Environment.GetEnvironmentVariable("NBXPLORER_BTCRPCURL");

Expand All @@ -144,7 +143,7 @@

if (PUSH_NOTIFICATIONS_ONESIGNAL_ENABLED)
{
PUSH_NOTIFICATIONS_ONESIGNAL_APP_ID = GetEnvironmentalVariableOrThrowIfNotTesting("PUSH_NOTIFICATIONS_ONESIGNAL_APP_ID", "if PUSH_NOTIFICATIONS_ONESIGNAL_ENABLED is set, PUSH_NOTIFICATIONS_ONESIGNAL_APP_ID");

Check warning on line 146 in src/Helpers/Constants.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Possible null reference assignment.

PUSH_NOTIFICATIONS_ONESIGNAL_API_BASE_PATH = GetEnvironmentalVariableOrThrowIfNotTesting("PUSH_NOTIFICATIONS_ONESIGNAL_API_BASE_PATH", "if PUSH_NOTIFICATIONS_ONESIGNAL_ENABLED is set,PUSH_NOTIFICATIONS_ONESIGNAL_API_BASE_PATH");

Expand All @@ -166,8 +165,6 @@

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
Loading