1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-26 17:37:36 +01:00

admin base uri setting, applied to login emails

This commit is contained in:
Kyle Spearrin 2018-04-16 20:35:53 -04:00
parent 795cf8e20e
commit dead022e83
31 changed files with 59 additions and 119 deletions

View File

@ -38,8 +38,7 @@ namespace Bit.Admin.Controllers
{
if(ModelState.IsValid)
{
await _signInManager.PasswordlessSignInAsync(model.Email,
Url.Action("Confirm", "Login", new { returnUrl = model.ReturnUrl }, Request.Scheme));
await _signInManager.PasswordlessSignInAsync(model.Email, model.ReturnUrl);
return RedirectToAction("Index", new
{
success = "If a valid admin user with this email address exists, " +

View File

@ -4,6 +4,8 @@
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"admin": "https://admin.bitwarden.com",
"internalAdmin": "https://admin.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"

View File

@ -8,6 +8,8 @@
"vault": "http://localhost:4001",
"api": "http://localhost:4000",
"identity": "http://localhost:33656",
"admin": "http://localhost:62911",
"internalAdmin": "http://localhost:62911",
"internalIdentity": "http://localhost:33656",
"internalApi": "http://localhost:4000",
"internalVault": "http://localhost:4001"

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://preview-vault.bitwarden.com",
"api": "https://preview-api.bitwarden.com",
"identity": "https://preview-identity.bitwarden.com",
"internalIdentity": "https://preview-identity.bitwarden.com",
"internalApi": "https://preview-api.bitwarden.com",
"internalVault": "https://preview-vault.bitwarden.com"
}
}
}

View File

@ -4,6 +4,8 @@
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"admin": "https://admin.bitwarden.com",
"internalAdmin": "https://admin.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"
}
}
}

View File

@ -8,6 +8,8 @@
"vault": "http://localhost:4001",
"api": "http://localhost:4000",
"identity": "http://localhost:33656",
"admin": "http://localhost:62911",
"internalAdmin": "http://localhost:62911",
"internalIdentity": "http://localhost:33656",
"internalApi": "http://localhost:4000",
"internalVault": "http://localhost:4001"

View File

@ -4,6 +4,8 @@
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"admin": "https://admin.bitwarden.com",
"internalAdmin": "https://admin.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com"
},
"braintree": {

View File

@ -8,6 +8,8 @@
"vault": "http://localhost:4001",
"api": "http://localhost:4000",
"identity": "http://localhost:33656",
"admin": "http://localhost:62911",
"internalAdmin": "http://localhost:62911",
"internalIdentity": "http://localhost:33656",
"internalApi": "http://localhost:4000",
"internalVault": "http://localhost:4001"

View File

@ -34,6 +34,8 @@ namespace Bit.Core
public string VaultWithHash => $"{Vault}/#";
public string Api { get; set; }
public string Identity { get; set; }
public string Admin { get; set; }
public string InternalAdmin { get; set; }
public string InternalIdentity { get; set; }
public string InternalApi { get; set; }
public string InternalVault { get; set; }

View File

@ -28,7 +28,7 @@ namespace Bit.Core.Identity
_mailService = mailService;
}
public async Task<SignInResult> PasswordlessSignInAsync(string email, string loginConfirmUrl)
public async Task<SignInResult> PasswordlessSignInAsync(string email, string returnUrl)
{
var user = await UserManager.FindByEmailAsync(email);
if(user == null)
@ -38,7 +38,7 @@ namespace Bit.Core.Identity
var token = await UserManager.GenerateUserTokenAsync(user, Options.Tokens.PasswordResetTokenProvider,
PasswordlessSignInPurpose);
await _mailService.SendPasswordlessSignInAsync(loginConfirmUrl, token, email);
await _mailService.SendPasswordlessSignInAsync(returnUrl, token, email);
return SignInResult.Success;
}

View File

@ -18,6 +18,6 @@ namespace Bit.Core.Services
Task SendOrganizationInviteEmailAsync(string organizationName, OrganizationUser orgUser, string token);
Task SendOrganizationAcceptedEmailAsync(string organizationName, string userEmail, IEnumerable<string> adminEmails);
Task SendOrganizationConfirmedEmailAsync(string organizationName, string email);
Task SendPasswordlessSignInAsync(string baseUrl, string token, string email);
Task SendPasswordlessSignInAsync(string returnUrl, string token, string email);
}
}

View File

@ -153,16 +153,16 @@ namespace Bit.Core.Services
}
}
public async Task SendPasswordlessSignInAsync(string baseUrl, string token, string email)
public async Task SendPasswordlessSignInAsync(string returnUrl, string token, string email)
{
try
{
await _primaryMailService.SendPasswordlessSignInAsync(baseUrl, token, email);
await _primaryMailService.SendPasswordlessSignInAsync(returnUrl, token, email);
}
catch(Exception e)
{
LogError(e);
await _backupMailService.SendPasswordlessSignInAsync(baseUrl, token, email);
await _backupMailService.SendPasswordlessSignInAsync(returnUrl, token, email);
}
}

View File

@ -171,10 +171,12 @@ namespace Bit.Core.Services
await _mailDeliveryService.SendEmailAsync(message);
}
public async Task SendPasswordlessSignInAsync(string baseUrl, string token, string email)
public async Task SendPasswordlessSignInAsync(string returnUrl, string token, string email)
{
var url = CoreHelpers.ExtendQuery(new Uri(baseUrl), new Dictionary<string, string>
var url = CoreHelpers.ExtendQuery(new Uri($"{_globalSettings.BaseServiceUri.Admin}/login/confirm"),
new Dictionary<string, string>
{
["returnUrl"] = returnUrl,
["email"] = email,
["token"] = token,
});
@ -183,7 +185,7 @@ namespace Bit.Core.Services
["url"] = url.ToString()
};
var message = await CreateMessageAsync("Continue Logging In", email, "PasswordlessSignIn", model);
var message = await CreateMessageAsync("[Admin] Continue Logging In", email, "PasswordlessSignIn", model);
message.MetaData.Add("SendGridBypassListManagement", true);
await _mailDeliveryService.SendEmailAsync(message);
}

View File

@ -203,12 +203,14 @@ namespace Bit.Core.Services
await _mailDeliveryService.SendEmailAsync(message);
}
public async Task SendPasswordlessSignInAsync(string baseUrl, string token, string email)
public async Task SendPasswordlessSignInAsync(string returnUrl, string token, string email)
{
var message = CreateDefaultMessage("Continue Logging In", email);
var message = CreateDefaultMessage("[Admin] Continue Logging In", email);
var url = CoreHelpers.ExtendQuery(new Uri(baseUrl), new Dictionary<string, string>
var url = CoreHelpers.ExtendQuery(new Uri($"{_globalSettings.BaseServiceUri.Admin}/login/confirm"),
new Dictionary<string, string>
{
["returnUrl"] = returnUrl,
["email"] = email,
["token"] = token,
});

View File

@ -62,7 +62,7 @@ namespace Bit.Core.Services
return Task.FromResult(0);
}
public Task SendPasswordlessSignInAsync(string baseUrl, string token, string email)
public Task SendPasswordlessSignInAsync(string returnUrl, string token, string email)
{
return Task.FromResult(0);
}

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://preview-vault.bitwarden.com",
"api": "https://preview-api.bitwarden.com",
"identity": "https://preview-identity.bitwarden.com",
"internalIdentity": "https://preview-identity.bitwarden.com",
"internalApi": "https://preview-api.bitwarden.com",
"internalVault": "https://preview-vault.bitwarden.com"
}
}
}

View File

@ -4,6 +4,8 @@
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"admin": "https://admin.bitwarden.com",
"internalAdmin": "https://admin.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"
}
}
}

View File

@ -6,6 +6,8 @@
"vault": "http://localhost:4001",
"api": "http://localhost:4000",
"identity": "http://localhost:33656",
"admin": "http://localhost:62911",
"internalAdmin": "http://localhost:62911",
"internalIdentity": "http://localhost:33656",
"internalApi": "http://localhost:4000",
"internalVault": "http://localhost:4001"

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://preview-vault.bitwarden.com",
"api": "https://preview-api.bitwarden.com",
"identity": "https://preview-identity.bitwarden.com",
"internalIdentity": "https://preview-identity.bitwarden.com",
"internalApi": "https://preview-api.bitwarden.com",
"internalVault": "https://preview-vault.bitwarden.com"
}
}
}

View File

@ -4,6 +4,8 @@
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"admin": "https://admin.bitwarden.com",
"internalAdmin": "https://admin.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"
}
}
}

View File

@ -8,6 +8,8 @@
"vault": "http://localhost:4001",
"api": "http://localhost:4000",
"identity": "http://localhost:33656",
"admin": "http://localhost:62911",
"internalAdmin": "http://localhost:62911",
"internalIdentity": "http://localhost:33656",
"internalApi": "http://localhost:4000",
"internalVault": "http://localhost:4001"

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://preview-vault.bitwarden.com",
"api": "https://preview-api.bitwarden.com",
"identity": "https://preview-identity.bitwarden.com",
"internalIdentity": "https://preview-identity.bitwarden.com",
"internalApi": "https://preview-api.bitwarden.com",
"internalVault": "https://preview-vault.bitwarden.com"
}
}
}

View File

@ -4,6 +4,8 @@
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"admin": "https://admin.bitwarden.com",
"internalAdmin": "https://admin.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"

View File

@ -1,12 +0,0 @@
{
"globalSettings": {
"baseServiceUri": {
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"
}
}
}

View File

@ -8,6 +8,8 @@
"vault": "http://localhost:4001",
"api": "http://localhost:4000",
"identity": "http://localhost:33656",
"admin": "http://localhost:62911",
"internalAdmin": "http://localhost:62911",
"internalIdentity": "http://localhost:33656",
"internalApi": "http://localhost:4000",
"internalVault": "http://localhost:4001"

View File

@ -4,6 +4,8 @@
"vault": "https://vault.bitwarden.com",
"api": "https://api.bitwarden.com",
"identity": "https://identity.bitwarden.com",
"admin": "https://admin.bitwarden.com",
"internalAdmin": "https://admin.bitwarden.com",
"internalIdentity": "https://identity.bitwarden.com",
"internalApi": "https://api.bitwarden.com",
"internalVault": "https://vault.bitwarden.com"

View File

@ -8,6 +8,8 @@
"vault": "http://localhost:4001",
"api": "http://localhost:4000",
"identity": "http://localhost:33656",
"admin": "http://localhost:62911",
"internalAdmin": "http://localhost:62911",
"internalIdentity": "http://localhost:33656",
"internalApi": "http://localhost:4000",
"internalVault": "http://localhost:4001"

View File

@ -41,6 +41,7 @@ namespace Bit.Setup
["globalSettings__baseServiceUri__vault"] = Url,
["globalSettings__baseServiceUri__api"] = $"{Url}/api",
["globalSettings__baseServiceUri__identity"] = $"{Url}/identity",
["globalSettings__baseServiceUri__admin"] = $"{Url}/admin",
["globalSettings__sqlServer__connectionString"] = $"\"{ dbConnectionString }\"",
["globalSettings__identityServer__certificatePassword"] = IdentityCertPassword,
["globalSettings__attachment__baseDirectory"] = $"{OutputDirectory}/core/attachments",
@ -126,6 +127,8 @@ globalSettings__selfHosted=true
globalSettings__baseServiceUri__vault=http://localhost
globalSettings__baseServiceUri__api=http://localhost/api
globalSettings__baseServiceUri__identity=http://localhost/identity
globalSettings__baseServiceUri__admin=http://localhost/admin
globalSettings__baseServiceUri__internalAdmin=http://admin:5000
globalSettings__baseServiceUri__internalIdentity=http://identity:5000
globalSettings__baseServiceUri__internalApi=http://api:5000
globalSettings__baseServiceUri__internalVault=http://web:5000