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

Added custom authentication support to Garnet. #648

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions libs/host/Configuration/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ private IAuthenticationSettings GetAuthenticationSettings(ILogger logger = null)
var aadAuthSettings = new AadAuthenticationSettings(AuthorizedAadApplicationIds?.Split(','), AadAudiences?.Split(','), AadIssuers?.Split(','), IssuerSigningTokenProvider.Create(AadAuthority, logger), AadValidateUsername.GetValueOrDefault());
return new AclAuthenticationAadSettings(AclFile, Password, aadAuthSettings);
default:
logger?.LogError("Unsupported authentication mode: {mode}", AuthenticationMode);
throw new Exception($"Authentication mode {AuthenticationMode} is not supported.");
logger?.LogWarning("Defaulting to NoAuth if authenticationSettingsOverride is not provided.");
Xizt marked this conversation as resolved.
Show resolved Hide resolved
return new NoAuthSettings();
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion libs/host/GarnetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Garnet.common;
using Garnet.networking;
using Garnet.server;
using Garnet.server.Auth.Settings;
using Microsoft.Extensions.Logging;
using Tsavorite.core;

Expand Down Expand Up @@ -76,7 +77,7 @@ public class GarnetServer : IDisposable
/// </summary>
/// <param name="commandLineArgs">Command line arguments</param>
/// <param name="loggerFactory">Logger factory</param>
public GarnetServer(string[] commandLineArgs, ILoggerFactory loggerFactory = null, bool cleanupDir = false)
public GarnetServer(string[] commandLineArgs, IAuthenticationSettings authenticationSettingsOverride = null, ILoggerFactory loggerFactory = null, bool cleanupDir = false)
Xizt marked this conversation as resolved.
Show resolved Hide resolved
{
Trace.Listeners.Add(new ConsoleTraceListener());

Expand Down Expand Up @@ -125,6 +126,7 @@ public GarnetServer(string[] commandLineArgs, ILoggerFactory loggerFactory = nul

// Assign values to GarnetServerOptions
this.opts = serverSettings.GetServerOptions(this.loggerFactory.CreateLogger("Options"));
this.opts.AuthSettings = authenticationSettingsOverride ?? this.opts.AuthSettings;
this.cleanupDir = cleanupDir;
this.InitializeServer();
}
Expand Down