microsoft / microsoft/aspire

Create KeycloakRealmResource to represent the address of a realm

Open
#5,092 6 comments 1 reaction 0 assignees View on GitHub
area-integrations keycloak
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

## Background and Motivation

A Keycloak server may have several realms and the realms are what's important for applications.

But, at the moment, `JwtBearerOptions` does not support service discovery for authority and Keycloak has its own way of constructing the base address of the realm.

It would be helpful, if "creating" a realm would create connection string for the realm.

## Proposed API

On the Aspire host, there would be a `AddReal` method that would create a connections string to the realm.

```csharp
var keycloak = builder.AddKeycloak(...);
var realm = keycloak.AddRealm(...);

var service = builder.AddProject<...>(...)
.WithEnvironment("Security__Authentication__JwtBearerOptions__Authority", realm)
:
```

## Usage Examples

On the service side, the service would only have to register the configuration:

```csharp
builder.Services
.AddOptions("Bearer")
.BindConfiguration("VisionBox:Security:Authentication:JwtBearerOptions")
.ValidateOnStart();
-->

## Complementary Designs

Import realm could return a connection string for the realm.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing Keycloak resource and import APIs, then trace how JwtBearerOptions currently receives its authority configuration. Define what the proposed AddRealm API and realm connection string must represent, and consider the usage examples as the completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
authentication, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.