/*
* dbMango
*
* Copyright 2025 Deutsche Bank AG
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using OpenTelemetry.Metrics;
namespace Rms.Service.Bootstrap;
///
/// Which authorization type to use
///
public enum AuthorizationType
{
///
/// use FxAdmin. User profiles read from the database
///
FxAdmin,
///
/// Use Abacus. Abacus calls used for authorization.
///
Abacus,
///
/// Do nor add any authorization. Application will handle it itself.
///
Skip
}
///
/// Options for configuring standard endpoint
///
///
[SuppressMessage("ReSharper", "PropertyCanBeMadeInitOnly.Global")]
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global")]
// ReSharper disable once UnusedTypeParameter
public class ServiceBootstrapOptions where T : class
{
// ReSharper disable UnusedAutoPropertyAccessor.Global
///
/// API service. Enable gRPC endpoints.
///
public bool EnableGrpc { get; set; } = true;
///
/// API service. Enable gRPC transcoding to Json REST calls.
///
public bool EnableGrpcTranscoding { get; set; } = true;
///
/// Service API version (example: v1) to use for Swagger
///
public string ApiVersion { get; set; } = "v1";
///
/// API service. Enable Oidc integration. Requires Oidc application onboarding.
///
public bool EnableOidc { get; set; } = true;
///
/// API service. Enable mTLS authentication. Requires service certificate.
///
public bool EnableMTLS { get; set; } = true;
///
/// Web application. Enable OAuth2. Requires Oidc application onboarding.
///
public bool EnableOpenIdConnect { get; set; }
///
/// API service. Enable builtin health checks.
///
public bool EnableHealthChecks { get; set; } = true;
///
/// Authorization source: FxAdmin or Abacus.
///
public AuthorizationType AuthorizeBy { get; set; } = AuthorizationType.Abacus;
///
/// Callback for additional OpenTelemetry configuration.
///
public Action? ConfigureOpenTelemetry { get; set; }
///
/// If you are using custom health checks this is your chance to configure them.
/// See https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?source=recommendations
///
public Action? ConfigureHealthChecks { get; set; }
///
/// Method for formatting health check result
///
public Func? HealthChecksWriter { get; set; }
}