Tuitio rebranding

master
Tudor Stanciu 2023-02-04 10:20:10 +02:00
parent 6ec6075c13
commit 18131ead03
8 changed files with 33 additions and 33 deletions

View File

@ -4,6 +4,6 @@
{
None,
Basic,
InhouseIdentity
Tuitio
}
}

View File

@ -55,8 +55,8 @@ namespace Netmash.Extensions.Swagger
options.SetAuthorization(authorizationType.ToString(), "Basic");
break;
case AuthorizationType.InhouseIdentity:
options.SetAuthorization(authorizationType.ToString(), "Identity");
case AuthorizationType.Tuitio:
options.SetAuthorization(authorizationType.ToString(), "Tuitio");
break;
default:

View File

@ -1,4 +1,4 @@
using IdentityServer.Wrapper;
using Tuitio.Wrapper;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Netmash.Security.Authentication.Identity.Abstractions;
@ -8,34 +8,34 @@ namespace Netmash.Security.Authentication.Identity
{
public static class AuthenticationExtensions
{
public static IServiceCollection AddIdentityAuthentication(this IServiceCollection services, string identityServerBaseAddress)
public static IServiceCollection AddTuitioAuthentication(this IServiceCollection services, string tuitioBaseAddress)
{
services.AddIdentityAuthentication(identityServerBaseAddress, new Models.AuthenticationOptions());
services.AddTuitioAuthentication(tuitioBaseAddress, new Models.AuthenticationOptions());
return services;
}
public static IServiceCollection AddIdentityAuthentication(this IServiceCollection services, string identityServerBaseAddress, IAuthenticationOptions authenticationOptions)
public static IServiceCollection AddTuitioAuthentication(this IServiceCollection services, string tuitioBaseAddress, IAuthenticationOptions options)
{
Validate(identityServerBaseAddress, authenticationOptions);
Validate(tuitioBaseAddress, options);
// Identity server
services.UseIdentityServices(identityServerBaseAddress);
services.AddSingleton(authenticationOptions);
// Tuitio
services.UseIdentityServices(tuitioBaseAddress);
services.AddSingleton(options);
// configure authentication
services.AddAuthentication("IdentityAuthentication")
.AddScheme<AuthenticationSchemeOptions, IdentityAuthenticationHandler>("IdentityAuthentication", null);
services.AddAuthentication("TuitioAuthentication")
.AddScheme<AuthenticationSchemeOptions, TuitioAuthenticationHandler>("TuitioAuthentication", null);
return services;
}
private static void Validate(string identityServerBaseAddress, IAuthenticationOptions authenticationOptions)
private static void Validate(string tuitioBaseAddress, IAuthenticationOptions options)
{
if (string.IsNullOrEmpty(identityServerBaseAddress))
throw new ArgumentException("Identity server base address must be provided.");
if (string.IsNullOrEmpty(tuitioBaseAddress))
throw new ArgumentException("Tuitio base address must be provided.");
var guestFuncDefined = authenticationOptions.AuthenticateAsGuest != null;
if (guestFuncDefined && string.IsNullOrEmpty(authenticationOptions.GuestUserName))
var guestFuncDefined = options.AuthenticateAsGuest != null;
if (guestFuncDefined && string.IsNullOrEmpty(options.GuestUserName))
throw new ArgumentException("Guest function is defined, but guest user name is not set.");
}
}

View File

@ -1,6 +1,4 @@
using IdentityServer.PublishedLanguage.Dto;
using IdentityServer.Wrapper.Services;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Netmash.Security.Authentication.Identity.Abstractions;
@ -11,17 +9,19 @@ using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Tuitio.PublishedLanguage.Dto;
using Tuitio.Wrapper.Services;
using c = Netmash.Security.Authentication.Identity.Constants;
namespace Netmash.Security.Authentication.Identity
{
public class IdentityAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
public class TuitioAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
private readonly IIdentityService _identityService;
private readonly IAuthenticationOptions _authenticationOptions;
private readonly ILogger<IdentityAuthenticationHandler> _logger;
private readonly ILogger<TuitioAuthenticationHandler> _logger;
public IdentityAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory loggerFactory, UrlEncoder encoder, ISystemClock clock, IIdentityService identityService, IAuthenticationOptions authenticationOptions, ILogger<IdentityAuthenticationHandler> logger)
public TuitioAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory loggerFactory, UrlEncoder encoder, ISystemClock clock, IIdentityService identityService, IAuthenticationOptions authenticationOptions, ILogger<TuitioAuthenticationHandler> logger)
: base(options, loggerFactory, encoder, clock)
{
_identityService = identityService;

View File

@ -2,16 +2,16 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>Add authentication handler with inhouse identity server</Description>
<Description>Add authentication handler with Tuitio</Description>
<PackageProjectUrl>https://lab.code-rove.com/gitea/bricks/netmash</PackageProjectUrl>
<RepositoryUrl>https://lab.code-rove.com/gitea/bricks/netmash</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>Netmash Authentication Identity</PackageTags>
<PackageTags>Netmash Authentication Tuitio</PackageTags>
<Version>1.0.8</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IdentityServer.Wrapper" Version="1.1.0" />
<PackageReference Include="Tuitio.Wrapper" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
</ItemGroup>

View File

@ -16,7 +16,7 @@ namespace Netmash.Test.Api.Extensions
new GuestRoute("/spot", 2)
};
public static IServiceCollection AddIdentityAuthentication(this IServiceCollection services, string identityServerBaseAddress)
public static IServiceCollection AddTuitioAuthentication(this IServiceCollection services, string tuitioBaseAddress)
{
var authenticationOptions = new AuthenticationOptions()
{
@ -30,7 +30,7 @@ namespace Netmash.Test.Api.Extensions
AcceptTokenFromQuery = true
};
services.AddIdentityAuthentication(identityServerBaseAddress, authenticationOptions);
services.AddTuitioAuthentication(tuitioBaseAddress, authenticationOptions);
return services;
}

View File

@ -24,10 +24,10 @@ namespace Netmash.Test.Api
public void ConfigureServices(IServiceCollection services)
{
// Add basic authentication
services.AddIdentityAuthentication(Configuration.GetSection("IdentityServer")["BaseAddress"]);
services.AddTuitioAuthentication(Configuration.GetSection("Tuitio")["BaseAddress"]);
services.AddControllers();
services.AddSwagger("Netmash.Test.Api", AuthorizationType.InhouseIdentity);
services.AddSwagger("Netmash.Test.Api", AuthorizationType.Tuitio);
services.AddMigration(DatabaseType.SQLite, MetadataLocation.Database);
}

View File

@ -11,8 +11,8 @@
}
},
"AllowedHosts": "*",
"IdentityServer": {
"Tuitio": {
//"BaseAddress": "http://localhost:5063/"
"BaseAddress": "https://lab.code-rove.com/identity-server-api/"
"BaseAddress": "https://lab.code-rove.com/tuitio/"
}
}