Skip to content

Commit

Permalink
Added custom authentication support to Garnet. (#648)
Browse files Browse the repository at this point in the history
* Added custom authenticator to support MISE.

* Need to extend GarnetAclAuthenticator while creating custom authenticator. Making it public

* Reverting public for GarnetAclAuthenticator

* Updated param name with Override suffix. Setting AuthSetting during Garnet server intiialization and removed custom auth enum

* Keeping default to throw exception.

* Moved new parameter to last for backward compatibility

* Adding IGarnetAclAuthenticator interface and updated corresponding references

* Revert "Adding IGarnetAclAuthenticator interface and updated corresponding references"

This reverts commit a2322fa.

* Made GarnetAclAuthenticator public

---------

Co-authored-by: Tejas Kulkarni (from Dev Box) <[email protected]>
Co-authored-by: Badrish Chandramouli <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2024
1 parent 810570e commit ad81de1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 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,9 @@ 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)
/// <param name="cleanupDir">Clean up directory.</param>
/// <param name="authenticationSettingsOverride">Override for custom authentication settings.</param>
public GarnetServer(string[] commandLineArgs, ILoggerFactory loggerFactory = null, bool cleanupDir = false, IAuthenticationSettings authenticationSettingsOverride = null)
{
Trace.Listeners.Add(new ConsoleTraceListener());

Expand Down Expand Up @@ -125,6 +128,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
2 changes: 1 addition & 1 deletion libs/server/Auth/GarnetACLAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Garnet.server.Auth
{
abstract class GarnetACLAuthenticator : IGarnetAuthenticator
public abstract class GarnetACLAuthenticator : IGarnetAuthenticator
{
/// <summary>
/// The Access Control List to authenticate users against
Expand Down

0 comments on commit ad81de1

Please sign in to comment.