first commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Domain
|
||||
{
|
||||
public class EmailRequest
|
||||
{
|
||||
public string Recipient { get; set; }
|
||||
public string Subject { get; set; }
|
||||
public string Body { get; set; }
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Landmark.OLA.Models;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Domain
|
||||
{
|
||||
public class StoredSettings : OlaModel
|
||||
{
|
||||
public DateTime LastUpdated { get; set; }
|
||||
[Required]
|
||||
public string LastUpdatedBy { get; set; }
|
||||
public bool ApplicationDisabled { get; set; }
|
||||
public string AppDisabledMessage { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Landmark.OLA.Models;
|
||||
using Landmark.OLA.Models.Addresses.Enums;
|
||||
using Landmark.OLA.Models.Individuals.Enums;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
using Landmark.OLA.Models.Loan.Enums;
|
||||
using static Landmark.OLA.Models.Loan.TermLengths;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Domain
|
||||
{
|
||||
public class UiSettings
|
||||
{
|
||||
public string AbaRouting => "275079714";
|
||||
|
||||
public Dictionary<string, string> Contact => new Dictionary<string, string>
|
||||
{
|
||||
{ "HelpPhone", "262-796-4500" },
|
||||
};
|
||||
|
||||
public Dictionary<string, string> Links => new Dictionary<string, string>
|
||||
{
|
||||
{ "PrivacyPolicy", "https://www.example.com/" },
|
||||
{ "MemberSite", "https://www.example.net" },
|
||||
{ "HomePage", "https://www.landmarkcu.com/"},
|
||||
};
|
||||
|
||||
public Dictionary<decimal, List<int>> MfdHomeAndRvByAmount = TermLengths.MfdHomeAndRvByAmount;
|
||||
|
||||
public List<int> HomeEquity = TermLengths.HomeEquity;
|
||||
|
||||
public List<int> Special = TermLengths.Special;
|
||||
|
||||
public List<int> MortgageRefiExpress = TermLengths.MortgageRefiExpress;
|
||||
|
||||
public List<int> VehiclePreApproval = TermLengths.VehiclePreApproval;
|
||||
|
||||
public Dictionary<int, List<int>> TermsByYear = TermLengths.TermsByYear;
|
||||
|
||||
public Dictionary<decimal, List<int>> BoatLoansByAmount = TermLengths.BoatLoansByAmount;
|
||||
|
||||
public Dictionary<decimal, List<int>> PowersportByAmount = TermLengths.PowersportByAmount;
|
||||
|
||||
public Dictionary<decimal, List<int>> SignatureByAmount = TermLengths.SignatureByAmount;
|
||||
|
||||
public Dictionary<LoanType, List<LoanPurpose.Purpose>> TypePurposes = LoanPurpose.TypePurposes;
|
||||
|
||||
public Dictionary<LoanType, Limit> Limits = LoanLimits.Limits;
|
||||
|
||||
public List<StateOption> StatesRequiringSpouseInformation = ValidationConstants.StatesRequiringSpouseInformation;
|
||||
|
||||
public List<StateOption> StateOptions = ((StateOption[])Enum.GetValues(typeof(StateOption))).ToList();
|
||||
|
||||
public Dictionary<Frequency, Limit> IncomeLimits = Models.Individuals.IncomeLimits.Limits;
|
||||
|
||||
public BranchConfig BranchMapping = null; // Provided by MongoDB
|
||||
|
||||
public BranchNameConfig BranchNameMapping = null; // Provided by MongoDB
|
||||
|
||||
public StoredSettings Configuration = null; // Provided by MongoDB
|
||||
|
||||
public List<UiTermOption> TermOptions = AvailableTermOptions;
|
||||
|
||||
public List<UiTermOption> TermOptionsNoYear = AvailableTermOptionsWithoutYears;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
namespace Landmark.OLA.Application.Common.Security
|
||||
{
|
||||
public class AzureActiveDirectoryOptions
|
||||
{
|
||||
public string ClientId { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
public string Instance { get; set; }
|
||||
public string Domain { get; set; }
|
||||
public string TenantId { get; set; }
|
||||
public string ValidAudience { get; set; }
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Security
|
||||
{
|
||||
public static class AzureAdServiceCollectionExtensions
|
||||
{
|
||||
public static AuthenticationBuilder AddAzureAdBearer(this AuthenticationBuilder builder)
|
||||
=> builder.AddAzureAdBearer(_ => { });
|
||||
|
||||
public static AuthenticationBuilder AddAzureAdBearer(this AuthenticationBuilder builder, Action<AzureActiveDirectoryOptions> configureOptions)
|
||||
{
|
||||
builder.Services.Configure(configureOptions);
|
||||
builder.Services.AddSingleton<IConfigureOptions<JwtBearerOptions>, ConfigureAzureOptions>();
|
||||
builder.AddJwtBearer();
|
||||
return builder;
|
||||
}
|
||||
|
||||
private class ConfigureAzureOptions : IConfigureNamedOptions<JwtBearerOptions>
|
||||
{
|
||||
private readonly AzureActiveDirectoryOptions _azureOptions;
|
||||
|
||||
public ConfigureAzureOptions(IOptions<AzureActiveDirectoryOptions> azureOptions)
|
||||
{
|
||||
_azureOptions = azureOptions.Value;
|
||||
}
|
||||
|
||||
public void Configure(string name, JwtBearerOptions options)
|
||||
{
|
||||
options.Audience = _azureOptions.ClientId;
|
||||
options.Authority = $"{_azureOptions.Instance}{_azureOptions.TenantId}";
|
||||
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidAudience = _azureOptions.ValidAudience
|
||||
};
|
||||
}
|
||||
|
||||
public void Configure(JwtBearerOptions options)
|
||||
{
|
||||
Configure(Options.DefaultName, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Landmark.OLA.Models.OnlineBanking;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Security
|
||||
{
|
||||
public class CookieService
|
||||
{
|
||||
|
||||
public static void SetAuthenticationCookie(IResponseCookies cookies, string token)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
var expiry = new DateTimeOffset(DateTime.UtcNow.AddMinutes(15));
|
||||
var options = new CookieOptions
|
||||
{
|
||||
SameSite = SameSiteMode.Lax,
|
||||
HttpOnly = true,
|
||||
Secure = true,
|
||||
Expires = expiry,
|
||||
Domain = "landmarkcu.com"
|
||||
};
|
||||
cookies
|
||||
.Append(Constants.TokenPayload, token, options);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetAuthorizationCookie(IResponseCookies cookies, string authorization)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(authorization))
|
||||
{
|
||||
var expiry = new DateTimeOffset(DateTime.UtcNow.AddMinutes(15));
|
||||
var options = new CookieOptions
|
||||
{
|
||||
SameSite = SameSiteMode.Lax,
|
||||
HttpOnly = false,
|
||||
Secure = true,
|
||||
Expires = expiry,
|
||||
Domain = "landmarkcu.com",
|
||||
};
|
||||
cookies
|
||||
.Append(Constants.TokenAuthorization, authorization, options);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExpireCookies(HttpContext context)
|
||||
{
|
||||
var currentCookies = context.Request.Cookies;
|
||||
var expiry = new DateTimeOffset(DateTime.UtcNow.AddDays(-1));
|
||||
var options = new CookieOptions
|
||||
{
|
||||
HttpOnly = false,
|
||||
Secure = true,
|
||||
Expires = expiry,
|
||||
Domain = ".landmarkcu.com"
|
||||
};
|
||||
if (currentCookies[Constants.TokenPayload] != null)
|
||||
{
|
||||
context.Response.Cookies
|
||||
.Delete(Constants.TokenPayload, options);
|
||||
}
|
||||
|
||||
if (currentCookies[Constants.TokenAuthorization] != null)
|
||||
{
|
||||
context.Response.Cookies
|
||||
.Delete(Constants.TokenAuthorization, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using Landmark.OLA.Models.Loan;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Security
|
||||
{
|
||||
public static class CosmosIdService
|
||||
{
|
||||
public static LoanContainer AppendCosmosId(LoanContainer loanContainer, string cosmosId)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(cosmosId))
|
||||
{
|
||||
loanContainer.Id = cosmosId;
|
||||
}
|
||||
return loanContainer;
|
||||
}
|
||||
|
||||
public static LoanContainer RemoveCosmosId(LoanContainer loanContainer)
|
||||
{
|
||||
loanContainer.LoanId = null;
|
||||
return loanContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Security
|
||||
{
|
||||
public static class ForwardedHeaderService
|
||||
{
|
||||
public static string GetRemoteIPAddress(HttpContext context)
|
||||
{
|
||||
var header = (context.Request.Headers["CF-Connecting-IP"].FirstOrDefault() ?? context.Request.Headers["X-Forwarded-For"].FirstOrDefault());
|
||||
if (IPAddress.TryParse(header, out IPAddress ip))
|
||||
{
|
||||
return ip.ToString();
|
||||
}
|
||||
return context.Connection.RemoteIpAddress.ToString();
|
||||
}
|
||||
|
||||
public static LoanContainer AppendIPAddress(LoanContainer loanContainer, HttpContext context)
|
||||
{
|
||||
loanContainer.LoanApplication.IPAddress = GetRemoteIPAddress(context);
|
||||
return loanContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using Landmark.OLA.Models.Loan;
|
||||
using Landmark.OLA.Models.OnlineBanking;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Security
|
||||
{
|
||||
public static class MemberIdService
|
||||
{
|
||||
public static LoanContainer AppendMemberInfo(LoanContainer loanContainer, OnlineBankingToken token)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(token?.MemberID) )
|
||||
{
|
||||
loanContainer.MemberId = token.MemberID;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(token?.IndividualID) )
|
||||
{
|
||||
loanContainer.IndividualId = token.IndividualID;
|
||||
}
|
||||
return loanContainer;
|
||||
}
|
||||
|
||||
public static LoanContainer RemoveMemberId(LoanContainer loanContainer)
|
||||
{
|
||||
loanContainer.MemberId = null;
|
||||
loanContainer.IndividualId = null;
|
||||
return loanContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Serilog;
|
||||
using OnlineBankingAuth.Tokens;
|
||||
|
||||
namespace Landmark.OLA.Application.Common.Security
|
||||
{
|
||||
public class RenewAuthenticatedSessionMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public RenewAuthenticatedSessionMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context, ITokenService tokenService)
|
||||
{
|
||||
await _next(context);
|
||||
try
|
||||
{
|
||||
CookieService.SetAuthenticationCookie(context.Response.Cookies, tokenService.RenewOnlineBankingJWT(context));
|
||||
CookieService.SetAuthorizationCookie(context.Response.Cookies, tokenService.RenewAuthorization(context));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Log.Fatal("Error renewing cookied", ex);
|
||||
// Could not refresh token :-( no biggie?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user