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