diff --git a/docs/deployment.md b/docs/deployment.md index 8def84407..657d96946 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -72,21 +72,6 @@ RelayServer deployments consist of multiple instances (pods) of different contai Configuration: * Provide a connection string to the RelayServer database -* Thinktecture.Relay.StatisticsApi - This component provides endpoints to retrieve usage data about the system from the database. For example you could - fetch this data in intervals and feed it into your monitoring or billing systems. Load on this component is based - on your internal usage only and should be fairly constant. - If not absolutley required we suggested not exposing this container to the public internet. Only have it available - for your internal administrative usages. Unless you have higher load or higher reliability requirements (i.e. for - monitoring) it should be fine to run only a single instance. - - **DO** create your own project using the RelayServer v3 NuGet packages. Use the corresponding persistence packages for - the database of your choice. - **Do NOT** use the example / development project and docker file from this repository in production. - - Configuration: - * Provide a connection string to the RelayServer database - ## Connector * Thinktecture.Relay.Connector diff --git a/docs/development-getting-started.md b/docs/development-getting-started.md index 344929904..28dbc0fc8 100644 --- a/docs/development-getting-started.md +++ b/docs/development-getting-started.md @@ -90,4 +90,4 @@ backing service classes. The way we structured the components listed above is ba so far and does not mean that this is the only way to deploy and use RelayServer. It might be the case that your specific use case demands or favours a different component layout, i.e. combining the -management- and statistics API together into a single host project, or even putting all server components together. +management API and RelayServer together into a single host project, or even putting all server components together. diff --git a/docs/glossary.md b/docs/glossary.md index 625a48212..f4905ca76 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -13,9 +13,9 @@ RelayServer v3 supports different types of authentication for different use case use OAuth 2 client credential authentication to be able to securely communicate with the [RelayServer](#relayserver). However you can customize and change that. -When you want to use the [Management API](#management-api) or the [Statistics API](#statistics-api), we suggest that you -use your own existing OIDC-based Identity Provider and configure your clients and the APIs to use this. -The demo service uses API keys authentication as an example. +When you want to use the [Management API](#management-api) we suggest that you use your own existing OIDC-based Identity +Provider and configure your clients and the APIs to use this. The demo service uses API keys authentication as an +example. ## B @@ -103,17 +103,6 @@ A _Response_ always corresponds to a [Request](#request). When the [Request](#re [Target](#target), the [Connector](#connector) will receive the _Response_ and send it back to the [RelayServer](#relayserver) to be passed back to the [Client](#client). -## S - -### Statistics API - -The _Statistics API_ is a service that you can host publicly alongside the [RelayServer](#relayserver) or only on your -private network. The _Statistics API_ will provide you with statistical data about the whole system, i.e. how many -[Requests](#request) have been handled in what time frame, for what [Tenant](#tenant) these were handled, how many bytes -were transferred, how many [Connectors](#connector) are connected and a lot of more data. - -In RelayServer v2, similar endpoints were an integral part of the RelayServer host process. - ## T ### Target diff --git a/docs/migration.md b/docs/migration.md index 4437d2673..f791f7742 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -18,10 +18,10 @@ installation to work, you now can choose to use either Microsoft SQL Server or P your own database connector for other database types. In order to be able to deploy and run a reliable RelayServer v3 installation you need to plan out which components you -want to deploy in what configuration. While you can host the management api and the statistics api in the same process -as the actual RelayServer, you might want to distribute them into several different hosting processes. +want to deploy in what configuration. While you can host the management api in the same process as the actual +RelayServer, you might want to distribute them into several different hosting processes. -Be aware that if you only use a single RabbitMQ host and this fails (i.e. because of a hardware issue), your whole +Be aware that if you only use a single RabbitMQ host and this fails (i.e. because of a hardware issue), your whole RelayServer will not be able to process any more requests. If you need a reliable setup, we strongly suggest to operate your RabbitMQ and the database in a fault tolerant cluster @@ -29,11 +29,11 @@ configuration on different physical machines. You also should operate at least t server component and the token security service in order to provide fault tolerance and some sort of load balancing. Depending on your use-case scenario it might be suitable to merge these two components into a single host project. -In regards to the management api and the statistics api, they are intended to be internal tools for you to help you -monitor and manage your installation. Depending on your needs you might get away with a single deployment of these -services. If you want you can also only spin up an instance of the management api when you have to change your settings -and shut it down otherwise to save resources. Alternatively, you can also use the management or statistics assemblies to -directly gather information or manage your tenants from your own internal tools and don't use the api at all. +In regards to the management api, it is intended to be an internal tool for you to help you to manage your installation. +Depending on your needs you might get away with a single deployment of this service. If you want you can also only spin +up an instance of the management api when you have to change your settings and shut it down otherwise to save resources. +Alternatively, you can also use the management assemblies to directly gather information or manage your tenants from +your own internal tools and don't use the api at all. If your are unsure if your deployment scenario is well suited for your specific use-case, you can of course contact Thinktecture AG. We do offer review and consulting services so that you can be sure that your deployment and operation @@ -63,12 +63,12 @@ You then should roll out all connectors to the "v2.9" intermediate connector sta ## Migrate to RelayServer v3 -Following your deployment plan, create the host projects for your RelayServer v3, management and statistics APIs. You -can use our docker examples as a starting point. We suggest using only our NuGet packages to build your RelayServer -system. Building from source might lead to possible unwanted modifications and makes troubleshooting extremely hard. +Following your deployment plan, create the host projects for your RelayServer v3 and management API. You can use our +docker examples as a starting point. We suggest using only our NuGet packages to build your RelayServer system. Building +from source might lead to possible unwanted modifications and makes troubleshooting extremely hard. -Be aware that we do not provide a ready-to run access control solution for the management and statistics APIs. If you -have an existing OIDC Identity Provider we suggest using this and to configure your API host projects to use this. +Be aware that we do not provide a ready-to run access control solution for the management API. If you have an existing +OIDC Identity Provider we suggest using this and to configure your API host projects to use this. Migrate your server-side interceptor to the new interfaces of v3. In most cases you should be able to re-use most of your existing logic and only have to adjust your code where it interacts with the actual request and response objects, diff --git a/src/Thinktecture.Relay.sln b/src/Thinktecture.Relay.sln index 879a33593..dc71efb38 100644 --- a/src/Thinktecture.Relay.sln +++ b/src/Thinktecture.Relay.sln @@ -68,8 +68,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Thinktecture.Relay.Manageme EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Thinktecture.Relay.Server.Docker", "docker\Thinktecture.Relay.Server.Docker\Thinktecture.Relay.Server.Docker.csproj", "{29B6CBFA-43A8-447E-90AB-6B22CD0EA413}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Thinktecture.Relay.StatisticsApi.Docker", "docker\Thinktecture.Relay.StatisticsApi.Docker\Thinktecture.Relay.StatisticsApi.Docker.csproj", "{055B9A9E-9A45-4100-BA64-378443F6AB73}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Thinktecture.Relay.Connector", "Thinktecture.Relay.Connector\Thinktecture.Relay.Connector.csproj", "{FF37E5FF-65D3-4EFD-B87F-8D456075402E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Thinktecture.Relay.Server.Protocols.SignalR", "Thinktecture.Relay.Server.Protocols.SignalR\Thinktecture.Relay.Server.Protocols.SignalR.csproj", "{1878FC63-129B-405E-B63B-386AB7CF0590}" @@ -147,10 +145,6 @@ Global {29B6CBFA-43A8-447E-90AB-6B22CD0EA413}.Debug|Any CPU.Build.0 = Debug|Any CPU {29B6CBFA-43A8-447E-90AB-6B22CD0EA413}.Release|Any CPU.ActiveCfg = Release|Any CPU {29B6CBFA-43A8-447E-90AB-6B22CD0EA413}.Release|Any CPU.Build.0 = Release|Any CPU - {055B9A9E-9A45-4100-BA64-378443F6AB73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {055B9A9E-9A45-4100-BA64-378443F6AB73}.Debug|Any CPU.Build.0 = Debug|Any CPU - {055B9A9E-9A45-4100-BA64-378443F6AB73}.Release|Any CPU.ActiveCfg = Release|Any CPU - {055B9A9E-9A45-4100-BA64-378443F6AB73}.Release|Any CPU.Build.0 = Release|Any CPU {FF37E5FF-65D3-4EFD-B87F-8D456075402E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FF37E5FF-65D3-4EFD-B87F-8D456075402E}.Debug|Any CPU.Build.0 = Debug|Any CPU {FF37E5FF-65D3-4EFD-B87F-8D456075402E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -190,7 +184,6 @@ Global {599D7AD9-7901-4A20-A81F-6C71E60A71DF} = {3126FA1D-9755-4842-BDE0-34F7EADF9969} {D1866E02-8665-4166-8F6D-ECED1BAAEF7E} = {3126FA1D-9755-4842-BDE0-34F7EADF9969} {29B6CBFA-43A8-447E-90AB-6B22CD0EA413} = {3126FA1D-9755-4842-BDE0-34F7EADF9969} - {055B9A9E-9A45-4100-BA64-378443F6AB73} = {3126FA1D-9755-4842-BDE0-34F7EADF9969} {4884F96C-5129-424F-9DDB-8DD91229D4B3} = {3126FA1D-9755-4842-BDE0-34F7EADF9969} {0E17E737-E4B5-4198-A784-D543187F15D0} = {D8D76BB9-1D64-43C5-9B7E-710CF4A35374} {1878FC63-129B-405E-B63B-386AB7CF0590} = {D8D76BB9-1D64-43C5-9B7E-710CF4A35374} diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/.gitignore b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/.gitignore deleted file mode 100644 index 3b51baec4..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -StatisticsApiDocumentation.xml diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Controllers/HealthController.cs b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Controllers/HealthController.cs deleted file mode 100644 index 1b7eb3d98..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Controllers/HealthController.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace Thinktecture.Relay.StatisticsApi.Docker.Controllers; - -/// -/// Provides health information for this API. -/// -[AllowAnonymous] -[Route("{controller}/{action}")] -public class HealthController : Controller -{ - /// - /// Returns the ready state of this api. - /// - /// An representing the state of the api. - [HttpGet] - public IActionResult Ready() - => Ok(); - - /// - /// Checks the health state of this api. - /// - /// An representing the state of the api. - [HttpGet] - public IActionResult Check() - => Ok(); -} diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Dockerfile b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Dockerfile deleted file mode 100644 index b0eff0101..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Dockerfile +++ /dev/null @@ -1,51 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build -WORKDIR /src - -# Copy only project files for restore -# Dependencies -COPY ./docker/Thinktecture.Relay.Docker/Thinktecture.Relay.Docker.csproj ./docker/Thinktecture.Relay.Docker/ -COPY ./Thinktecture.Relay.Abstractions/Thinktecture.Relay.Abstractions.csproj ./Thinktecture.Relay.Abstractions/ -COPY ./Thinktecture.Relay.Server.Abstractions/Thinktecture.Relay.Server.Abstractions.csproj ./Thinktecture.Relay.Server.Abstractions/ -COPY ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore/Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.csproj ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore/ -COPY ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.PostgreSql/Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.PostgreSql.csproj ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.PostgreSql/ -COPY ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.SqlServer/Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.SqlServer.csproj ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.SqlServer/ -COPY ./docker/Thinktecture.Relay.StatisticsApi.Docker/Thinktecture.Relay.StatisticsApi.Docker.csproj ./docker/Thinktecture.Relay.StatisticsApi.Docker/ - -# Restore packages -RUN dotnet restore /src/docker/Thinktecture.Relay.StatisticsApi.Docker/Thinktecture.Relay.StatisticsApi.Docker.csproj - -# Copy everything else that's required for the build -COPY ./Directory.Build.props ./ -COPY ./docker/Thinktecture.Relay.Docker ./docker/Thinktecture.Relay.Docker -COPY ./Thinktecture.Relay.Abstractions ./Thinktecture.Relay.Abstractions -COPY ./Thinktecture.Relay.Server.Abstractions ./Thinktecture.Relay.Server.Abstractions -COPY ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore -COPY ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.PostgreSql ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.PostgreSql -COPY ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.SqlServer ./Thinktecture.Relay.Server.Persistence.EntityFrameworkCore.SqlServer -COPY ./docker/Thinktecture.Relay.StatisticsApi.Docker ./docker/Thinktecture.Relay.StatisticsApi.Docker - -RUN dotnet publish /src/docker/Thinktecture.Relay.StatisticsApi.Docker/Thinktecture.Relay.StatisticsApi.Docker.csproj --no-restore -c Release -o /app - -# Create final image -FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim -WORKDIR /app -RUN adduser -u 5678 --disabled-password --gecos "" relay && chown -R relay /app - -# Add .NET Diagnostic Counters -RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists && \ - wget -O dotnet-counters https://aka.ms/dotnet-counters/linux-x64 && \ - chmod +x dotnet-counters && \ - apt purge wget --yes - -# Address CIS-DI-0008 -RUN chmod u-s /usr/bin/gpasswd /usr/bin/chsh /bin/umount /bin/mount /sbin/unix_chkpwd /usr/bin/expiry /usr/bin/newgrp /usr/bin/chage /usr/bin/chfn /usr/bin/wall /usr/bin/passwd /bin/su && \ - chmod g-s /usr/bin/gpasswd /usr/bin/chsh /bin/umount /bin/mount /sbin/unix_chkpwd /usr/bin/expiry /usr/bin/newgrp /usr/bin/chage /usr/bin/chfn /usr/bin/wall /usr/bin/passwd /bin/su - -USER relay -COPY --chown=relay --from=build /app . - -EXPOSE 5000 - -ENV ASPNETCORE_URLS=http://+:5000 - -ENTRYPOINT ["dotnet", "Thinktecture.Relay.StatisticsApi.Docker.dll"] diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Program.cs b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Program.cs deleted file mode 100644 index 094809e65..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Program.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.Hosting; -using Serilog; -using Thinktecture.Relay.Docker; - -namespace Thinktecture.Relay.StatisticsApi.Docker; - -/// -/// The statistics api program. -/// -// ReSharper disable once ClassNeverInstantiated.Global; Main entry point -public class Program -{ - /// - /// The main entry point for the statistics api. - /// - /// The command line arguments. - /// A return code for the OS to handle. - public static async Task Main(string[] args) - { - try - { - var host = CreateHostBuilder(args).Build(); - - await host.RunAsync(); - } - catch (Exception ex) - { - Console.WriteLine("A fatal error cause service crash: {0}", ex); - Log.Fatal(ex, "A fatal error cause service crash"); - return 1; - } - finally - { - await Log.CloseAndFlushAsync(); - } - - return 0; - } - - /// - /// Creates a host builder. - /// - /// The command line args. - /// An instance of an . - // ReSharper disable once MemberCanBePrivate.Global; Could be used by dotnet cli tools like EF cli. - public static IHostBuilder CreateHostBuilder(string[] args) - => DockerUtils.CreateHostBuilder("StatisticsApi", args); -} diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Properties/launchSettings.json b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Properties/launchSettings.json deleted file mode 100644 index 7a146ff9b..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Properties/launchSettings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "profiles": { - "Thinktecture.Relay.StatisticsApi.Docker": { - "commandName": "Project", - "launchBrowser": false, - "launchUrl": "", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:5007;http://localhost:5006" - }, - "Docker": { - "commandName": "Docker", - "launchBrowser": false, - "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", - "publishAllPorts": true, - "useSSL": true - } - } -} diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/ServiceCollectionExtensions.cs b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/ServiceCollectionExtensions.cs deleted file mode 100644 index a7d04c9f3..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -namespace Thinktecture.Relay.StatisticsApi.Docker; - -public static class ServiceCollectionExtensions -{ - public static IServiceCollection AddRelayServerDbContext(this IServiceCollection services, - IConfiguration configuration) - { - if ("SqlServer".Equals(configuration.GetValue("DatabaseType"), - StringComparison.InvariantCultureIgnoreCase)) - return Server.Persistence.EntityFrameworkCore.SqlServer.ServiceCollectionExtensions - .AddRelayServerDbContext(services, configuration.GetConnectionString("SqlServer") - ?? throw new InvalidOperationException("No 'SqlServer' connection string found.")); - - return Server.Persistence.EntityFrameworkCore.PostgreSql.ServiceCollectionExtensions - .AddRelayServerDbContext(services, configuration.GetConnectionString("PostgreSql") - ?? throw new InvalidOperationException("No 'PostgreSql' connection string found.")); - } -} diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Startup.cs b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Startup.cs deleted file mode 100644 index a054a01a4..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Startup.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace Thinktecture.Relay.StatisticsApi.Docker; - -internal class Startup -{ - public IConfiguration Configuration { get; } - - public Startup(IConfiguration configuration) - => Configuration = configuration; - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddControllers(); - - services.AddRelayServerDbContext(Configuration); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseRouting(); - - app.UseAuthorization(); - app.UseAuthentication(); - - app.UseEndpoints(endpoints => endpoints.MapControllers()); - } -} diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Thinktecture.Relay.StatisticsApi.Docker.csproj b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Thinktecture.Relay.StatisticsApi.Docker.csproj deleted file mode 100644 index ecb723393..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/Thinktecture.Relay.StatisticsApi.Docker.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net8.0 - - - - - StatisticsApiDocumentation.xml - - - - - - - - - - - diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/appsettings.Development.json b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/appsettings.Development.json deleted file mode 100644 index 469175310..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/appsettings.Development.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "Serilog": { - "MinimumLevel": { - "Default": "Verbose", - "Override": { - "Microsoft": "Information", - "System": "Information" - } - }, - "WriteTo": [ - { - "Name": "Seq", - "Args": { - "ServerUrl": "http://localhost:5341" - } - } - ] - }, - "ConnectionStrings": { - "PostgreSql": "host=localhost;database=relayserver;username=relayserver;password=" - } -} diff --git a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/appsettings.json b/src/docker/Thinktecture.Relay.StatisticsApi.Docker/appsettings.json deleted file mode 100644 index 2c63c0851..000000000 --- a/src/docker/Thinktecture.Relay.StatisticsApi.Docker/appsettings.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -}