Skip to content

Commit

Permalink
feat: ws-federation client managemrnt
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed May 1, 2021
1 parent c494635 commit 5833048
Show file tree
Hide file tree
Showing 10 changed files with 364 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ else
<div class="w-100"></div>
<div class="col">
<ul class="list-inline text-lowercase">
<li class="list-inline-item text-lowercase">
<a href="@(NavigationManager.Uri)#grantTypes" @onclick='() => ScrollTo("grantTypes")' @onclick:preventDefault>@Localizer["grant types"]</a>
</li>
@if (Model.IsWebClient())
@if (Model.ProtocolType == OIDC)
{
<li class="list-inline-item">
<a href="@(NavigationManager.Uri)#consent" @onclick='() => ScrollTo("consent")' @onclick:preventDefault>@Localizer["consent"]</a>
<li class="list-inline-item text-lowercase">
<a href="@(NavigationManager.Uri)#grantTypes" @onclick='() => ScrollTo("grantTypes")' @onclick:preventDefault>@Localizer["grant types"]</a>
</li>
}
@if (IsWebClient())
{
@if (Model.ProtocolType == OIDC)
{
<li class="list-inline-item">
<a href="@(NavigationManager.Uri)#consent" @onclick='() => ScrollTo("consent")' @onclick:preventDefault>@Localizer["consent"]</a>
</li>
}
<li class="list-inline-item">
<a href="@(NavigationManager.Uri)#urls" @onclick='() => ScrollTo("urls")' @onclick:preventDefault>@Localizer["urls"]</a>
</li>
Expand All @@ -61,9 +67,12 @@ else
<li class="list-inline-item">
<a href="@(NavigationManager.Uri)#tokens" @onclick='() => ScrollTo("tokens")' @onclick:preventDefault>@Localizer["tokens"]</a>
</li>
<li class="list-inline-item">
<a href="@(NavigationManager.Uri)#secrets" @onclick='() => ScrollTo("secrets")' @onclick:preventDefault>@Localizer["secrets"]</a>
</li>
@if (Model.ProtocolType == OIDC)
{
<li class="list-inline-item">
<a href="@(NavigationManager.Uri)#secrets" @onclick='() => ScrollTo("secrets")' @onclick:preventDefault>@Localizer["secrets"]</a>
</li>
}
<li class="list-inline-item">
<a href="@(NavigationManager.Uri)#claims" @onclick='() => ScrollTo("claims")' @onclick:preventDefault>@Localizer["claims"]</a>
</li>
Expand All @@ -79,6 +88,38 @@ else
<div class="entity-details">
<div class="card mb-3">
<div class="card-body">
<div class="form-group row">
<label class="col col-form-label">
@Localizer["protocol type"]
</label>
<div class="col-lg-10 col-sm-12 form-inline">
@if (IsNew)
{
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="protocol-type"
value="0"
checked="@(Model.ProtocolType == OIDC)"
@onchange="@(() => SetProtcolType(OIDC))" />
<label class="form-check-label" for="oidc">OIDC</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="protocol-type"
value="1"
checked="@(Model.ProtocolType == WSFED)"
@onchange="@(() => SetProtcolType(WSFED))" />
<label class="form-check-label" for="wsfed">WS-Federation</label>
</div>
}
else if (Model.ProtocolType == OIDC)
{
<span class="form-control-plaintext">OIDC</span>
}
else
{
<span class="form-control-plaintext">WS-Federation</span>
}
</div>
</div>
<div class="form-group row">
<label class="col col-form-label">
</label>
Expand Down Expand Up @@ -123,28 +164,34 @@ else
<AuthorizeCheckbox Name="front-channel-logout-uri-required" Label="@Localizer["front channel logout uri required"]" @bind-Value="@Model.FrontChannelLogoutSessionRequired" />
</div>
</div>
<div class="form-group row">
<label class="col col-form-label" for="back-channel-logout-uri">
@Localizer["back channel logout uri"]
</label>
<div class="col-lg-10 col-sm-12">
<AuthorizeText Id="back-channel-logout-uri" Placeholder="https://theidserver.com/logout" @bind-Value="@Model.BackChannelLogoutUri" MaxLength="2000" />
<AuthorizeCheckbox Name="back-channel-logout-uri-required" Label="@Localizer["back channel logout uri required"]" @bind-Value="@Model.BackChannelLogoutSessionRequired" />
@if (Model.ProtocolType == OIDC)
{
<div class="form-group row">
<label class="col col-form-label" for="back-channel-logout-uri">
@Localizer["back channel logout uri"]
</label>
<div class="col-lg-10 col-sm-12">
<AuthorizeText Id="back-channel-logout-uri" Placeholder="https://theidserver.com/logout" @bind-Value="@Model.BackChannelLogoutUri" MaxLength="2000" />
<AuthorizeCheckbox Name="back-channel-logout-uri-required" Label="@Localizer["back channel logout uri required"]" @bind-Value="@Model.BackChannelLogoutSessionRequired" />
</div>
</div>
</div>
}
</div>
</div>
<div id="grantTypes" class="card mb-3">
<div class="card-header">
<div class="row">
<h5 class="col">@Localizer["Grant types"]</h5>
@if (Model.ProtocolType == OIDC)
{
<div id="grantTypes" class="card mb-3">
<div class="card-header">
<div class="row">
<h5 class="col">@Localizer["Grant types"]</h5>
</div>
</div>
<div class="card-body">
<ClientGrantTypes Model="@Model" />
</div>
</div>
<div class="card-body">
<ClientGrantTypes Model="@Model" />
</div>
</div>
@if (IsWebClient())
}
@if (IsWebClient() && Model.ProtocolType == OIDC)
{
<div id="consent" class="card mb-3">
<div class="card-header">
Expand All @@ -156,6 +203,9 @@ else
<ClientConsents Model="@Model" />
</div>
</div>
}
@if (IsWebClient())
{
<ClientUrisPanel Model="@Model" />
<div id="providers" class="card mb-3">
<div class="card-header">
Expand Down Expand Up @@ -188,20 +238,23 @@ else
<ClientTokens Model="@Model" />
</div>
</div>
<div id="secrets" class="card mb-3">
<div class="card-header">
<EntitySubGridTitle Text="@Localizer["Secrets"]" Collection="@Model.ClientSecrets" CreateModel="CreateSecret" />
</div>
<div class="card-body">
<ClientSecrets Collection="@Model.ClientSecrets" />
@if (Model.ClientSecrets.Any())
{
<div class="col">
<AuthorizeCheckbox Name="require-secret" Label="@Localizer["require secret"]" @bind-Value="@Model.RequireClientSecret" />
</div>
}
@if (Model.ProtocolType == OIDC)
{
<div id="secrets" class="card mb-3">
<div class="card-header">
<EntitySubGridTitle Text="@Localizer["Secrets"]" Collection="@Model.ClientSecrets" CreateModel="CreateSecret" />
</div>
<div class="card-body">
<ClientSecrets Collection="@Model.ClientSecrets" />
@if (Model.ClientSecrets.Any())
{
<div class="col">
<AuthorizeCheckbox Name="require-secret" Label="@Localizer["require secret"]" @bind-Value="@Model.RequireClientSecret" />
</div>
}
</div>
</div>
</div>
}
<div id="claims" class="card mb-3">
<div class="card-header">
<EntitySubGridTitle Text="@Localizer["Claims"]" Collection="@Model.ClientClaims" CreateModel="CreateClaim" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace Aguacongas.TheIdServer.BlazorApp.Pages.Client
{
public partial class Client
{
public static readonly string OIDC = "oidc";
public static readonly string WSFED = "wsfed";

private bool _filtered;
private bool _isWebClient;

Expand Down Expand Up @@ -94,13 +97,23 @@ protected override void RemoveNavigationProperty<TEntity>(TEntity entity)
}
}

protected override void OnEntityUpdated(Type entityType, Entity.IEntityId entityModel)
protected override Task<object> UpdateAsync(Type entityType, object entity)
{
if (entity is Entity.ClientUri clientUri && string.IsNullOrWhiteSpace(clientUri.Uri))
{
return base.DeleteAsync(entityType, entity);
}

return base.UpdateAsync(entityType, entity);
}

protected override Task<object> CreateAsync(Type entityType, object entity)
{
if (entityType == typeof(Entity.ClientGrantType))
if (entity is Entity.ClientUri clientUri && string.IsNullOrWhiteSpace(clientUri.Uri))
{
return;
return Task.FromResult(entity);
}
base.OnEntityUpdated(entityType, entityModel);
return base.CreateAsync(entityType, entity);
}

private void FilterFocusChanged(bool hasFocus)
Expand Down Expand Up @@ -143,5 +156,11 @@ private Task AddResource(Entity.EntityResourceKind kind)
HandleModificationState.EntityCreated(entity);
return Task.CompletedTask;
}

private void SetProtcolType(string protocolType)
{
Model.ProtocolType = protocolType;
StateHasChanged();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@
</td>
</RowTemplate>
</EntitiesGrid>
@if (Collection.Any())
@if (Model.ProtocolType == "oidc" && Collection.Any())
{
<div class="col">
<div class="form-group row">
<label class="col-2 col-form-label" for="clientUri">
@Localizer["claims prefix"]
</label>
<div class="col-lg-10 col-sm-12">
<div class="row col-4">
<AuthorizeText Id="clientUri" Placeholder="@Localizer["prefix"]" @bind-Value="@Model.ClientClaimsPrefix" MaxLength="250" />
<div class="col">
<div class="form-group row">
<label class="col-2 col-form-label" for="clientUri">
@Localizer["claims prefix"]
</label>
<div class="col-lg-10 col-sm-12">
<div class="row col-4">
<AuthorizeText Id="clientUri" Placeholder="@Localizer["prefix"]" @bind-Value="@Model.ClientClaimsPrefix" MaxLength="250" />
</div>
</div>
<label class="col-2 col-form-label">
</label>
<div class="col-lg-10 col-sm-12">
<AuthorizeCheckbox Label="@Localizer["always send claims"]" @bind-Value="@Model.AlwaysSendClientClaims" />
</div>
</div>
<label class="col-2 col-form-label">
</label>
<div class="col-lg-10 col-sm-12">
<AuthorizeCheckbox Label="@Localizer["always send claims"]" @bind-Value="@Model.AlwaysSendClientClaims" />
</div>
</div>
</div>
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
</ul>
</div>
</div>
<div class="row">
<div class="col">
<AuthorizeCheckbox Name="allow-offline-access" Label="@Localizer["allow offline access"]" @bind-Value="@Model.AllowOfflineAccess" />
@if (Model.ProtocolType == "oidc")
{
<div class="row">
<div class="col">
<AuthorizeCheckbox Name="allow-offline-access" Label="@Localizer["allow offline access"]" @bind-Value="@Model.AllowOfflineAccess" />
</div>
</div>
</div>
}
Loading

0 comments on commit 5833048

Please sign in to comment.