mirror of
https://github.com/bitwarden/server.git
synced 2025-01-22 21:51:22 +01:00
yubico global settings
This commit is contained in:
parent
c30efcaef0
commit
1fc441b6e8
@ -34,6 +34,10 @@
|
||||
"notificationHub": {
|
||||
"connectionString": "SECRET",
|
||||
"hubName": "SECRET"
|
||||
},
|
||||
"yubico": {
|
||||
"clientid": "SECRET",
|
||||
"key": "SECRET"
|
||||
}
|
||||
},
|
||||
"IpRateLimitOptions": {
|
||||
|
@ -14,6 +14,7 @@
|
||||
public virtual DataProtectionSettings DataProtection { get; set; } = new DataProtectionSettings();
|
||||
public virtual DocumentDbSettings DocumentDb { get; set; } = new DocumentDbSettings();
|
||||
public virtual NotificationHubSettings NotificationHub { get; set; } = new NotificationHubSettings();
|
||||
public virtual YubicoSettings Yubico { get; set; } = new YubicoSettings();
|
||||
|
||||
public class SqlServerSettings
|
||||
{
|
||||
@ -71,5 +72,11 @@
|
||||
public string ConnectionString { get; set; }
|
||||
public string HubName { get; set; }
|
||||
}
|
||||
|
||||
public class YubicoSettings
|
||||
{
|
||||
public string ClientId { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,13 @@ namespace Bit.Core.Identity
|
||||
{
|
||||
public class YubicoOtpTokenProvider : IUserTwoFactorTokenProvider<User>
|
||||
{
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
public YubicoOtpTokenProvider(GlobalSettings globalSettings)
|
||||
{
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
public Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<User> manager, User user)
|
||||
{
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.YubiKey);
|
||||
@ -41,7 +48,7 @@ namespace Bit.Core.Identity
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
var client = new YubicoClient("TODO", "TODO");
|
||||
var client = new YubicoClient(_globalSettings.Yubico.ClientId, _globalSettings.Yubico.ClientId);
|
||||
var response = client.Verify(token);
|
||||
return Task.FromResult(response.Status == YubicoResponseStatus.Ok);
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ namespace Bit.Core.Utilities
|
||||
.AddUserStore<UserStore>()
|
||||
.AddRoleStore<RoleStore>()
|
||||
.AddTokenProvider<AuthenticatorTokenProvider>(TwoFactorProviderType.Authenticator.ToString())
|
||||
.AddTokenProvider<YubicoOtpTokenProvider>(TwoFactorProviderType.YubiKey.ToString())
|
||||
.AddTokenProvider<DuoTokenProvider>(TwoFactorProviderType.Duo.ToString())
|
||||
.AddTokenProvider<EmailTokenProvider<User>>(TokenOptions.DefaultEmailProvider);
|
||||
|
||||
return identityBuilder;
|
||||
|
Loading…
Reference in New Issue
Block a user