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, None,
Basic, Basic,
InhouseIdentity Tuitio
} }
} }

View File

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

View File

@ -1,4 +1,4 @@
using IdentityServer.Wrapper; using Tuitio.Wrapper;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Netmash.Security.Authentication.Identity.Abstractions; using Netmash.Security.Authentication.Identity.Abstractions;
@ -8,34 +8,34 @@ namespace Netmash.Security.Authentication.Identity
{ {
public static class AuthenticationExtensions 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; 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 // Tuitio
services.UseIdentityServices(identityServerBaseAddress); services.UseIdentityServices(tuitioBaseAddress);
services.AddSingleton(authenticationOptions); services.AddSingleton(options);
// configure authentication // configure authentication
services.AddAuthentication("IdentityAuthentication") services.AddAuthentication("TuitioAuthentication")
.AddScheme<AuthenticationSchemeOptions, IdentityAuthenticationHandler>("IdentityAuthentication", null); .AddScheme<AuthenticationSchemeOptions, TuitioAuthenticationHandler>("TuitioAuthentication", null);
return services; return services;
} }
private static void Validate(string identityServerBaseAddress, IAuthenticationOptions authenticationOptions) private static void Validate(string tuitioBaseAddress, IAuthenticationOptions options)
{ {
if (string.IsNullOrEmpty(identityServerBaseAddress)) if (string.IsNullOrEmpty(tuitioBaseAddress))
throw new ArgumentException("Identity server base address must be provided."); throw new ArgumentException("Tuitio base address must be provided.");
var guestFuncDefined = authenticationOptions.AuthenticateAsGuest != null; var guestFuncDefined = options.AuthenticateAsGuest != null;
if (guestFuncDefined && string.IsNullOrEmpty(authenticationOptions.GuestUserName)) if (guestFuncDefined && string.IsNullOrEmpty(options.GuestUserName))
throw new ArgumentException("Guest function is defined, but guest user name is not set."); 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 Microsoft.AspNetCore.Authentication;
using IdentityServer.Wrapper.Services;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Netmash.Security.Authentication.Identity.Abstractions; using Netmash.Security.Authentication.Identity.Abstractions;
@ -11,17 +9,19 @@ using System.Net.Http.Headers;
using System.Security.Claims; using System.Security.Claims;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Threading.Tasks; using System.Threading.Tasks;
using Tuitio.PublishedLanguage.Dto;
using Tuitio.Wrapper.Services;
using c = Netmash.Security.Authentication.Identity.Constants; using c = Netmash.Security.Authentication.Identity.Constants;
namespace Netmash.Security.Authentication.Identity namespace Netmash.Security.Authentication.Identity
{ {
public class IdentityAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions> public class TuitioAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{ {
private readonly IIdentityService _identityService; private readonly IIdentityService _identityService;
private readonly IAuthenticationOptions _authenticationOptions; 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) : base(options, loggerFactory, encoder, clock)
{ {
_identityService = identityService; _identityService = identityService;

View File

@ -2,16 +2,16 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <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> <PackageProjectUrl>https://lab.code-rove.com/gitea/bricks/netmash</PackageProjectUrl>
<RepositoryUrl>https://lab.code-rove.com/gitea/bricks/netmash</RepositoryUrl> <RepositoryUrl>https://lab.code-rove.com/gitea/bricks/netmash</RepositoryUrl>
<RepositoryType>Git</RepositoryType> <RepositoryType>Git</RepositoryType>
<PackageTags>Netmash Authentication Identity</PackageTags> <PackageTags>Netmash Authentication Tuitio</PackageTags>
<Version>1.0.8</Version> <Version>1.0.8</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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" /> <PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
</ItemGroup> </ItemGroup>

View File

@ -16,7 +16,7 @@ namespace Netmash.Test.Api.Extensions
new GuestRoute("/spot", 2) 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() var authenticationOptions = new AuthenticationOptions()
{ {
@ -30,7 +30,7 @@ namespace Netmash.Test.Api.Extensions
AcceptTokenFromQuery = true AcceptTokenFromQuery = true
}; };
services.AddIdentityAuthentication(identityServerBaseAddress, authenticationOptions); services.AddTuitioAuthentication(tuitioBaseAddress, authenticationOptions);
return services; return services;
} }

View File

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

View File

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