Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Beispiel: /servicedmcore/CoreIdentity/2/?fields=Id,Nachname,VornameLanguage

AccessDeniedReplacementString="Denied"

Code Block
languagejson
{
    "Id": 2,
    "Nachname": {
        "WasAccessDenied": false,
        "Value": "Burkhard"
    },
    "Vorname": {
        "WasAccessDenied": true,
        "Value": null
    }
}
Code Block
languagejson
{
    "Id": 2,
    "Nachname": "Burkhard",
    "Vorname": "Denied"
}

...

Es können mehrere Clients mit unterschiedlichen Konfigurationen registriert werden. Dazu muss pro Konfiguration ein Interface deklariert. Diese können anschlissend via DependencyInjection konsumiert werden.

Die neuen Interfaces dürfen keine zusätzlichen Member enthalten!

Beispielkonfiguration

Code Block
languagec#
public interface IApiV2ClientUserContext : IApiV2Client
{
}
public interface IApiV2ClientAdminContext : IApiV2Client
{
}

public class Startup
{
	public void ConfigureServices(IServiceCollection services)
	{
		services.AddApiV2ClientWithHttpContextAuthentication<IApiV2ClientUserContext>(o =>
		{
			o.ApiBaseUri = new Uri("https://localhost:8000/apiv2");
			//o.ExplodeFlatChainProperties = false;
			//o.AccessDeniedReplacementString = ">>AccessDenied<<";
		});
		services.AddOpenIdConnectCookieAuthentication<IApiV2ClientUserContext>(options =>
		{
			options.Authority = "https://coslogin.local:5000";
			options.RequireHttpsMetadata = false; // dev only
			options.ClientId = "[OpenID Client Id]";
			options.ClientSecret = "[OpenID Client Secret]";
			options.ResponseType = "code";
			options.ResponseMode = "form_post";
			options.Scope.Add("roles");
			options.Scope.Add("profile");
			options.Scope.Add("offline_access");
			options.SaveTokens = true;
			options.GetClaimsFromUserInfoEndpoint = true;
			options.CallbackPath = "/signin-oidc";
			options.UsePkce = true;
		});
		services.AddApiV2ClientWithOpenIdPasswordFlow<IApiV2ClientAdminContext>(o =>
		{
			o.Authority = new Uri("https://coslogin.local:5000");
			o.ApiBaseUri = new Uri("https://localhost:8000/apiv2");
			o.ClientId = "[OpenID Client Id]";
			o.ClientSecret = "[OpenID Client Secret]";
			o.Username = "[OpenID User Name]";
			o.Password = "[OpenID User Password]";
			//o.ExplodeFlatChainProperties = false;
			//o.AccessDeniedReplacementString = ">>AccessDenied<<";
		});
	}
}