Initial commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
|
||||
namespace Backend.Security.Authentication {
|
||||
public class JwtTokenAuthenticationHandlerOptions : AuthenticationSchemeOptions {
|
||||
// Options for the authentication handler.
|
||||
// Currently: None
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Backend.Options;
|
||||
|
||||
namespace Backend.Security.Authentication {
|
||||
public class JwtTokenAuthenticationOptions : OptionsFromConfiguration {
|
||||
public override string Position => "Authentication";
|
||||
|
||||
public string RefreshTokenExpirationTimeInHours { get; set; }
|
||||
public string AccessTokenExpirationTimeInMinutes { get; set; }
|
||||
public string DebugAccessToken { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Backend.Options {
|
||||
public abstract class OptionsFromConfiguration {
|
||||
public abstract string Position { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Backend.Options {
|
||||
public static class OptionsFromConfigurationExtensions {
|
||||
public static T AddOptionsFromConfiguration<T>(this IServiceCollection services, IConfiguration configuration)
|
||||
where T : OptionsFromConfiguration {
|
||||
T optionsInstance = (T)Activator.CreateInstance(typeof(T));
|
||||
if (optionsInstance == null) return null;
|
||||
string position = optionsInstance.Position;
|
||||
services.Configure((Action<T>)(options => {
|
||||
IConfigurationSection section = configuration.GetSection(position);
|
||||
if (section != null) {
|
||||
section.Bind(options);
|
||||
}
|
||||
}));
|
||||
return optionsInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user