mirror of https://github.com/abpframework/abp.git
committed by
GitHub
2 changed files with 43 additions and 5 deletions
@ -1,15 +1,53 @@ |
|||
namespace Volo.Docs.Documents.FullSearch.Elastic |
|||
using System; |
|||
using Nest; |
|||
using Volo.Abp; |
|||
|
|||
namespace Volo.Docs.Documents.FullSearch.Elastic |
|||
{ |
|||
public class DocsElasticSearchOptions |
|||
{ |
|||
public bool Enable { get; set; } |
|||
|
|||
public string IndexName { get; set; } |
|||
|
|||
protected Action<ConnectionSettings> AuthenticationAction { get; set; } |
|||
|
|||
public DocsElasticSearchOptions() |
|||
{ |
|||
Enable = false; |
|||
IndexName = "abp_documents"; |
|||
} |
|||
|
|||
public bool Enable { get; set; } |
|||
public DocsElasticSearchOptions UseBasicAuthentication(string username, string password) |
|||
{ |
|||
Check.NotNullOrEmpty(username, nameof(username)); |
|||
Check.NotNullOrEmpty(password, nameof(password)); |
|||
|
|||
public string IndexName { get; set; } |
|||
AuthenticationAction = settings => |
|||
{ |
|||
settings.BasicAuthentication(username, password); |
|||
}; |
|||
|
|||
return this; |
|||
} |
|||
|
|||
public DocsElasticSearchOptions UseApiKeyAuthentication(string id, string apiKey) |
|||
{ |
|||
Check.NotNullOrEmpty(id, nameof(id)); |
|||
Check.NotNullOrEmpty(apiKey, nameof(apiKey)); |
|||
|
|||
AuthenticationAction = settings => |
|||
{ |
|||
settings.ApiKeyAuthentication(id, apiKey); |
|||
}; |
|||
|
|||
return this; |
|||
} |
|||
|
|||
public ConnectionSettings Authenticate(ConnectionSettings connectionSettings) |
|||
{ |
|||
AuthenticationAction?.Invoke(connectionSettings); |
|||
return connectionSettings; |
|||
} |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue