Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for v4 #330

Merged
merged 36 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5f8c41b
Update Welcome documentation
bart-vmware Oct 7, 2024
ebd37dc
Update Bootstrap documentation
bart-vmware Oct 2, 2024
1e8d625
Update Configuration documentation
bart-vmware Oct 2, 2024
88c8a9f
Update Logging documentation
bart-vmware Oct 3, 2024
d88fe24
Update Management documentation
bart-vmware Oct 4, 2024
b9e43d6
Update File Shares documentation
bart-vmware Oct 4, 2024
ca060d9
Update Connectors documentation
bart-vmware Oct 4, 2024
6380ad9
Update Discovery documentation
bart-vmware Oct 4, 2024
7836649
Update Initializr documentation
bart-vmware Oct 21, 2024
f041480
Update Tracing documentation (needs work)
bart-vmware Nov 18, 2024
f744ffb
Update Security documentation (needs work)
bart-vmware Nov 18, 2024
2441919
update metadata-layer-changed filter
TimHess Nov 18, 2024
2a9bd55
Guides: add top banner to every file, revert preliminary changes (pac…
bart-vmware Nov 19, 2024
9762915
Apply suggestions from code review
bart-vmware Nov 20, 2024
7451f2e
Review feedback: remove note for old Tanzu versions
bart-vmware Nov 20, 2024
c5abcd2
Review feedback: remove conference materials
bart-vmware Nov 20, 2024
f4011ca
Apply suggestions from code review
bart-vmware Nov 20, 2024
b792b1a
Review feedback: update banner for Steeltoe v2
bart-vmware Nov 20, 2024
fba618a
Review feedback: update remaining banners with suggested text
bart-vmware Nov 20, 2024
b0ad843
Review feedback: recommend BootstrapLogger
bart-vmware Nov 20, 2024
14aa9ee
Review feedback: remove the note that only Eureka can be used with di…
bart-vmware Nov 20, 2024
70cc3c2
Review feedback: clarify exposure settings
bart-vmware Nov 20, 2024
fc2ff27
Review feedback: remove Windows-only note on thread dumps
bart-vmware Nov 20, 2024
3d49b48
Review feedback: update another banner for v2
bart-vmware Nov 20, 2024
16cb0b9
Review feedback: Updated banners for messaging guide
bart-vmware Nov 20, 2024
c030760
Review feedback: Add note for 'beans'
bart-vmware Nov 20, 2024
7cdf9cc
Apply suggestions from code review
bart-vmware Nov 21, 2024
4cec129
Review feedback: Add KeysToSanitize
bart-vmware Nov 21, 2024
c616ab9
Review feedback: repeat tip on AddAllActuators
bart-vmware Nov 21, 2024
5088f63
Review feedback: indicate defaults for SBA
bart-vmware Nov 21, 2024
b7a16a2
Trim trailing whitespace in *.md, ensure blank line before EOF
bart-vmware Nov 21, 2024
ab7887b
Replace TABs with spaces in *.md
bart-vmware Nov 21, 2024
e303565
Trim trailing whitespace in other non-binary files, ensure blank line…
bart-vmware Nov 21, 2024
fe2d569
Replace TABs with spaces in other non-binary files
bart-vmware Nov 21, 2024
8da7c4a
Review feedback: clarify CF security
bart-vmware Nov 21, 2024
0b1a165
Review feedback: alternate port doesn't apply to /cloudfoundryapplica…
bart-vmware Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build-and-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ jobs:
metadata-layer-changed:
- .github/workflows/build-and-stage.yml
- Dockerfile-metadata
- '/api-*.*'
- 'api/**'
- 'articles/**'
- 'guides/**'
- build-metadata.sh
- docfx.json
- name: Declare image versions
Expand Down
2 changes: 1 addition & 1 deletion api/v2/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Steeltoe adds four additional configuration providers to the preceding list:
* Placeholder resolvers
* RandomValue generator

The following sections provide more more detail on each of these new providers.
The following sections provide more detail on each of these new providers.
2 changes: 1 addition & 1 deletion api/v3/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Steeltoe adds additional configuration providers to the preceding list:
* RandomValue generator
* Spring Cloud Config Server

The following sections provide more more detail on each of these new providers.
The following sections provide more detail on each of these new providers.
4 changes: 2 additions & 2 deletions api/v3/security/mtls.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The above example will create self-signed certificates with an OrgId of `a8fef16

### Securing Endpoints

In order to use identity certificates for authorization in a service application, services need to be configured and activated and polices need to be applied.
In order to use identity certificates for authorization in a service application, services need to be configured and activated and policies need to be applied.

#### Adding and using services

Expand Down Expand Up @@ -76,7 +76,7 @@ public void Configure(IApplicationBuilder app, ...)

>These steps are only required on services that are receiving mTLS-secured requests

#### Applying Authorization Polices
#### Applying Authorization Policies

Steeltoe includes policies for validating that a request came from an application in the same org or the space. Once you have done the work in the `Startup` class, you can secure endpoints by using the standard ASP.NET Core `Authorize` attribute with one of these security policies.

Expand Down
113 changes: 51 additions & 62 deletions api/v4/bootstrap/index.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,85 @@
# Application Bootstrapping

In order to improve the Steeltoe developer experience, this feature allows the configuration of most Steeltoe components with a single line of code in your application. The package is named [`Steeltoe.Bootstrap.AutoConfiguration`](https://github.com/SteeltoeOSS/Steeltoe/tree/main/src/Bootstrap/src/AutoConfiguration), and it works by applying the same extensions that are already included in Steeltoe packages to automatically wire up each of those components.
To improve the Steeltoe developer experience, this feature allows the configuration of most Steeltoe components with a single line of code in your application. The package is named [`Steeltoe.Bootstrap.AutoConfiguration`](https://github.com/SteeltoeOSS/Steeltoe/tree/main/src/Bootstrap/src/AutoConfiguration), and it works by calling the same extension methods that are already included in Steeltoe packages to automatically wire up each of those components.

Get started by adding a reference to the AutoConfiguration package (you may want to add other Steeltoe references at this point too, see [the table below](#supported-steeltoe-packages) for the full list of what's supported now):
Get started by adding a reference to the AutoConfiguration package (you may want to add other Steeltoe references at this point too, see [the table below](#supported-steeltoe-packages) for the full list of what's supported):

```xml
<ItemGroup>
<PackageReference Include="Steeltoe.Bootstrap.AutoConfiguration" Version="4.0.0" />
</ItemGroup>
```
dotnet add package Steeltoe.Bootstrap.AutoConfiguration
```

After adding the NuGet reference(s), simply include `.AddSteeltoe()` like you see in this example and you're all set with the basic implementation:
After adding the NuGet reference(s), simply include `.AddSteeltoe()` like you see in the code below and you're all set with the basic implementation.

```csharp
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Steeltoe.Bootstrap.AutoConfiguration;

namespace WebApplication1
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.AddSteeltoe();
}
}

var builder = WebApplication.CreateBuilder(args);
builder.AddSteeltoe();
```

## Supported Steeltoe Packages

`Steeltoe.Bootstrap.AutoConfiguration` is not a meta-package. In order for a Steeltoe feature to be automatically bootstrapped in the application, the appropriate NuGet package must also referenced. The following table describes the Steeltoe package that is required to light up a feature and any additional packages that may also be required:
`Steeltoe.Bootstrap.AutoConfiguration` is not a meta-package. In order for a Steeltoe feature to be automatically bootstrapped in the application, the appropriate NuGet package must also be referenced. The following table describes the Steeltoe package that is required to light up a feature and any additional packages that may also be installed:

| Feature Description | Steeltoe Package |Additional Package Required |
| Feature Description | Steeltoe Package | Additional Packages |
| --- | --- | --- |
| [Config Server Configuration](../configuration/config-server-provider.md) | `Steeltoe.Configuration.ConfigServer` | N/A |
| [Cloud Foundry Configuration](../configuration/cloud-foundry-provider.md) |`Steeltoe.Configuration.CloudFoundry` | N/A |
| [Random Value Provider](../configuration/random-value-provider.md) |`Steeltoe.Configuration.RandomValue` | N/A |
| [Placeholder Resolver](../configuration/placeholder-provider.md) |`Steeltoe.Configuration.Placeholder` | N/A |
| [Connectors*](../connectors/index.md) |`Steeltoe.Connectors` | Supported driver (MySQL, PostgreSQL, RabbitMQ, SQL Server, etc) |
| [Dynamic Serilog](../logging/serilog-logger.md) | `Steeltoe.Logging.DynamicSerilog` | N/A |
| [Service Discovery](../discovery/index.md) |`Steeltoe.Discovery.Client` | Desired client (Eureka, Consul, Configuration) |
| [Config Server Configuration Provider](../configuration/config-server-provider.md) | `Steeltoe.Configuration.ConfigServer` | Optional: `Steeltoe.Discovery.Eureka` to use discovery-first |
| [Cloud Foundry Configuration Provider](../configuration/cloud-foundry-provider.md) |`Steeltoe.Configuration.CloudFoundry` | N/A |
| [Random Value Configuration Provider](../configuration/random-value-provider.md) |`Steeltoe.Configuration.RandomValue` | N/A |
| [Placeholder Configuration Provider](../configuration/placeholder-provider.md) |`Steeltoe.Configuration.Placeholder` | N/A |
| [Encrypted Configuration Provider](../configuration/decryption-provider.md) | `Steeltoe.Configuration.Encryption` | N/A |
| [Spring Boot Configuration Provider](../configuration/spring-boot-provider.md) | `Steeltoe.Configuration.SpringBoot` | N/A |
| [Connectors](../connectors/index.md) |`Steeltoe.Connectors` | Required: Supported driver [^1] (MySQL, PostgreSQL, SQL Server, MongoDB, CosmosDB, Redis, RabbitMQ) |
| [Eureka Service Discovery](../discovery/netflix-eureka.md) |`Steeltoe.Discovery.Eureka` | Optional: `Steeltoe.Management.Endpoint` for health checks |
| [Consul Service Discovery](../discovery/hashicorp-consul.md) |`Steeltoe.Discovery.Consul` | N/A |
| [Configuration-based Service Discovery](../discovery/configuration-based.md) |`Steeltoe.Discovery.Configuration` | N/A |
| [Dynamic Logging](../logging/dynamic-logging-provider.md) | `Steeltoe.Logging.DynamicLogger` | N/A |
| [Dynamic Logging with Serilog](../logging/serilog-logger.md) | `Steeltoe.Logging.DynamicSerilog` | N/A |
| [Actuators](../management/index.md) | `Steeltoe.Management.Endpoint` | N/A |
| [Distributed Tracing](../tracing/index.md) | `Steeltoe.Management.Tracing` | OpenTelemetry Exporter (Zipkin, Jaeger, OTLP) |
| [Cloud Foundry Container Identity](../security/mtls.md#configure-settings) | `Steeltoe.Security.Authentication.CloudFoundry` | N/A |
| [Distributed Tracing](../tracing/index.md) | `Steeltoe.Management.Tracing` | Required: OpenTelemetry Exporter (Zipkin, Jaeger, OTLP) |

>\* Individual connector clients will only be configured if a corresponding supported driver NuGet package reference is also included.
[^1]: Individual connector clients will only be configured if a corresponding supported driver NuGet package reference is also included.

## Excluding Components

If you wish to exclude a component from the automatic bootstrap process, you may add the feature's assembly name to the exclusions list. One example where this feature would be desired is if you want to control the order configuration providers are added. This example shows how to provide the exclusions list:
If you wish to exclude a component from the automatic bootstrap process, you may add the feature's assembly name to the exclusions list. One example where this feature would be desired is if you want to control the order in which configuration providers are added. This example shows how to provide exclusions:

```csharp
public static IHostBuilder CreateHostBuilder(string[] args)
{
List<string> myExclusions = new () { SteeltoeAssemblyNames.SteeltoeConfigurationConfigServer };
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.AddSteeltoe(myExclusions);
}
using Steeltoe.Bootstrap.AutoConfiguration;

HashSet<string> assemblyNamesToExclude = [SteeltoeAssemblyNames.ConfigurationConfigServer];
builder.AddSteeltoe(assemblyNamesToExclude);
```

>The static class `SteeltoeAssemblyNames` is `public` so that you can easily find the name of any specific assembly to exclude.
> [!TIP]
> The static class `SteeltoeAssemblyNames` enables to easily find the name of any specific assembly to exclude.

## Logging Inside Config Providers
## Logging inside Configuration Providers

For some Steeltoe components, primarily configuration providers, providing a `LoggerFactory` is required to retrieve logs for debugging. Use the optional parameter to provide one as needed:

```csharp
public static IHostBuilder CreateHostBuilder(string[] args)
using Microsoft.Extensions.Logging.Debug;
using Steeltoe.Bootstrap.AutoConfiguration;

var loggerFactory = LoggerFactory.Create(loggingBuilder =>
{
LoggerFactory loggerFactory = new (new List<ILoggerProvider> { new DebugLoggerProvider() });
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.AddSteeltoe(loggerFactory: loggerFactory);
}
loggingBuilder.AddDebug(); // or: loggingBuilder.AddConsole();
loggingBuilder.SetMinimumLevel(LogLevel.Debug);
});

builder.AddSteeltoe(loggerFactory);
```

Alternatively, you can use `BootstrapLoggerFactory`. It logs to the console until the service container has been built.
Once the service container has become available, it automatically upgrades existing loggers to use the application configuration.

```csharp
using Steeltoe.Bootstrap.AutoConfiguration;
using Steeltoe.Common.Logging;

var loggerFactory = BootstrapLoggerFactory.CreateConsole();
builder.AddSteeltoe(loggerFactory);
```

## Limitations
Expand Down
Loading
Loading