diff --git a/src/extensions/swagger/Netmash.Extensions.Swagger/Constants/AuthorizationType.cs b/src/extensions/swagger/Netmash.Extensions.Swagger/Constants/AuthorizationType.cs index 3f2476f..f270fdb 100644 --- a/src/extensions/swagger/Netmash.Extensions.Swagger/Constants/AuthorizationType.cs +++ b/src/extensions/swagger/Netmash.Extensions.Swagger/Constants/AuthorizationType.cs @@ -4,6 +4,6 @@ { None, Basic, - InhouseIdentity + Tuitio } } diff --git a/src/extensions/swagger/Netmash.Extensions.Swagger/SwaggerExtensions.cs b/src/extensions/swagger/Netmash.Extensions.Swagger/SwaggerExtensions.cs index bd0b68c..68f22c8 100644 --- a/src/extensions/swagger/Netmash.Extensions.Swagger/SwaggerExtensions.cs +++ b/src/extensions/swagger/Netmash.Extensions.Swagger/SwaggerExtensions.cs @@ -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: diff --git a/src/security/authentication/Netmash.Security.Authentication.Identity/AuthenticationExtensions.cs b/src/security/authentication/Netmash.Security.Authentication.Identity/AuthenticationExtensions.cs index d6f6dc9..bdf557b 100644 --- a/src/security/authentication/Netmash.Security.Authentication.Identity/AuthenticationExtensions.cs +++ b/src/security/authentication/Netmash.Security.Authentication.Identity/AuthenticationExtensions.cs @@ -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("IdentityAuthentication", null); + services.AddAuthentication("TuitioAuthentication") + .AddScheme("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."); } } diff --git a/src/security/authentication/Netmash.Security.Authentication.Identity/IdentityAuthenticationHandler.cs b/src/security/authentication/Netmash.Security.Authentication.Identity/IdentityAuthenticationHandler.cs index 95e9ca7..2cf2658 100644 --- a/src/security/authentication/Netmash.Security.Authentication.Identity/IdentityAuthenticationHandler.cs +++ b/src/security/authentication/Netmash.Security.Authentication.Identity/IdentityAuthenticationHandler.cs @@ -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 + public class TuitioAuthenticationHandler : AuthenticationHandler { private readonly IIdentityService _identityService; private readonly IAuthenticationOptions _authenticationOptions; - private readonly ILogger _logger; + private readonly ILogger _logger; - public IdentityAuthenticationHandler(IOptionsMonitor options, ILoggerFactory loggerFactory, UrlEncoder encoder, ISystemClock clock, IIdentityService identityService, IAuthenticationOptions authenticationOptions, ILogger logger) + public TuitioAuthenticationHandler(IOptionsMonitor options, ILoggerFactory loggerFactory, UrlEncoder encoder, ISystemClock clock, IIdentityService identityService, IAuthenticationOptions authenticationOptions, ILogger logger) : base(options, loggerFactory, encoder, clock) { _identityService = identityService; diff --git a/src/security/authentication/Netmash.Security.Authentication.Identity/Netmash.Security.Authentication.Identity.csproj b/src/security/authentication/Netmash.Security.Authentication.Identity/Netmash.Security.Authentication.Identity.csproj index 3411d8f..320b90d 100644 --- a/src/security/authentication/Netmash.Security.Authentication.Identity/Netmash.Security.Authentication.Identity.csproj +++ b/src/security/authentication/Netmash.Security.Authentication.Identity/Netmash.Security.Authentication.Identity.csproj @@ -2,16 +2,16 @@ net6.0 - Add authentication handler with inhouse identity server + Add authentication handler with Tuitio https://lab.code-rove.com/gitea/bricks/netmash https://lab.code-rove.com/gitea/bricks/netmash Git - Netmash Authentication Identity + Netmash Authentication Tuitio 1.0.8 - + diff --git a/src/test/Netmash.Test.Api/Extensions/AuthenticationExtensions.cs b/src/test/Netmash.Test.Api/Extensions/AuthenticationExtensions.cs index 4485fd7..062d35e 100644 --- a/src/test/Netmash.Test.Api/Extensions/AuthenticationExtensions.cs +++ b/src/test/Netmash.Test.Api/Extensions/AuthenticationExtensions.cs @@ -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; } diff --git a/src/test/Netmash.Test.Api/Startup.cs b/src/test/Netmash.Test.Api/Startup.cs index 0cf505d..97fcf9e 100644 --- a/src/test/Netmash.Test.Api/Startup.cs +++ b/src/test/Netmash.Test.Api/Startup.cs @@ -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); } diff --git a/src/test/Netmash.Test.Api/appsettings.json b/src/test/Netmash.Test.Api/appsettings.json index 304cec0..25dda1e 100644 --- a/src/test/Netmash.Test.Api/appsettings.json +++ b/src/test/Netmash.Test.Api/appsettings.json @@ -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/" } }