Skip to content

Commit

Permalink
fix(OryAdmin): support removal of client token lifespans
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha committed Apr 11, 2024
1 parent 11c6d0f commit ce69e35
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 27 deletions.
36 changes: 26 additions & 10 deletions OryAdmin/Components/Pages/OAuth2/Clients/EditLifespans.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
else
{
<form @onsubmit="SubmitForm">
<div class="box p-5">
<div class="message is-info p-2">
<p>Format the durations as "1h0m0s" or similar.</p>
<p>Leave a field empty to use the configured hydra default lifespan.</p>
</div>
</div>
<div class="box p-5 @(string.IsNullOrWhiteSpace(_errorMessage) ? "is-hidden" : "")">
<div class="message is-warning p-2">
@_errorMessage
Expand All @@ -27,8 +33,9 @@ else
Access token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.RefreshTokenGrantAccessTokenLifespan"
@onchange="args => _lifespans.RefreshTokenGrantAccessTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.RefreshTokenGrantAccessTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -37,8 +44,9 @@ else
ID token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.RefreshTokenGrantIdTokenLifespan"
@onchange="args => _lifespans.RefreshTokenGrantIdTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.RefreshTokenGrantIdTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -47,8 +55,9 @@ else
Refresh token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.RefreshTokenGrantRefreshTokenLifespan"
@onchange="args => _lifespans.RefreshTokenGrantRefreshTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.RefreshTokenGrantRefreshTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -61,8 +70,9 @@ else
Access token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.AuthorizationCodeGrantAccessTokenLifespan"
@onchange="args => _lifespans.AuthorizationCodeGrantAccessTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.AuthorizationCodeGrantAccessTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -71,8 +81,9 @@ else
ID token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.AuthorizationCodeGrantIdTokenLifespan"
@onchange="args => _lifespans.AuthorizationCodeGrantIdTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.AuthorizationCodeGrantIdTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -81,8 +92,9 @@ else
Refresh token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.AuthorizationCodeGrantRefreshTokenLifespan"
@onchange="args => _lifespans.AuthorizationCodeGrantRefreshTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.AuthorizationCodeGrantRefreshTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -95,8 +107,9 @@ else
Access token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.ClientCredentialsGrantAccessTokenLifespan"
@onchange="args => _lifespans.ClientCredentialsGrantAccessTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.ClientCredentialsGrantAccessTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -109,8 +122,9 @@ else
Access token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.JwtBearerGrantAccessTokenLifespan"
@onchange="args => _lifespans.JwtBearerGrantAccessTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.JwtBearerGrantAccessTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -123,8 +137,9 @@ else
Access token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.ImplicitGrantAccessTokenLifespan"
@onchange="args => _lifespans.ImplicitGrantAccessTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.ImplicitGrantAccessTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand All @@ -133,8 +148,9 @@ else
ID token
<div class="control">
<input type="text" class="input"
placeholder="hydra default value"
value="@_lifespans.ImplicitGrantIdTokenLifespan"
@onchange="args => _lifespans.ImplicitGrantIdTokenLifespan = args.Value?.ToString()"/>
@onchange="args => _lifespans.ImplicitGrantIdTokenLifespan = args.Value is string value && string.IsNullOrWhiteSpace(value) ? null : args.Value?.ToString()"/>
</div>
</label>
</div>
Expand Down
122 changes: 106 additions & 16 deletions OryAdmin/Components/Pages/OAuth2/Clients/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,43 @@ else
</thead>
<tbody>
<tr>
<td>ID token</td>
<td>@_client.RefreshTokenGrantIdTokenLifespan.ToStringOrDash()</td>
<td>Access token</td>
@if (string.IsNullOrWhiteSpace(_client.RefreshTokenGrantAccessTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.RefreshTokenGrantAccessTokenLifespan</td>
}
</tr>
<tr>
<td>Access token</td>
<td>@_client.RefreshTokenGrantAccessTokenLifespan.ToStringOrDash()</td>
<td>ID token</td>
@if (string.IsNullOrWhiteSpace(_client.RefreshTokenGrantIdTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.RefreshTokenGrantIdTokenLifespan</td>
}
</tr>
<tr>
<td>Refresh token</td>
<td>@_client.RefreshTokenGrantRefreshTokenLifespan.ToStringOrDash()</td>
@if (string.IsNullOrWhiteSpace(_client.RefreshTokenGrantRefreshTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.RefreshTokenGrantRefreshTokenLifespan</td>
}
</tr>
</tbody>
</table>
Expand All @@ -272,16 +299,43 @@ else
</thead>
<tbody>
<tr>
<td>ID token</td>
<td>@_client.AuthorizationCodeGrantIdTokenLifespan.ToStringOrDash()</td>
<td>Access token</td>
@if (string.IsNullOrWhiteSpace(_client.AuthorizationCodeGrantAccessTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.AuthorizationCodeGrantAccessTokenLifespan</td>
}
</tr>
<tr>
<td>Access token</td>
<td>@_client.AuthorizationCodeGrantAccessTokenLifespan.ToStringOrDash()</td>
<td>ID token</td>
@if (string.IsNullOrWhiteSpace(_client.AuthorizationCodeGrantIdTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.AuthorizationCodeGrantIdTokenLifespan</td>
}
</tr>
<tr>
<td>Refresh token</td>
<td>@_client.AuthorizationCodeGrantRefreshTokenLifespan.ToStringOrDash()</td>
@if (string.IsNullOrWhiteSpace(_client.AuthorizationCodeGrantRefreshTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.AuthorizationCodeGrantRefreshTokenLifespan</td>
}
</tr>
</tbody>
</table>
Expand All @@ -294,7 +348,16 @@ else
<tbody>
<tr>
<td>Access token</td>
<td>@_client.ClientCredentialsGrantAccessTokenLifespan.ToStringOrDash()</td>
@if (string.IsNullOrWhiteSpace(_client.ClientCredentialsGrantAccessTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.ClientCredentialsGrantAccessTokenLifespan</td>
}
</tr>
</tbody>
</table>
Expand All @@ -307,7 +370,16 @@ else
<tbody>
<tr>
<td>Access Token</td>
<td>@_client.JwtBearerGrantAccessTokenLifespan.ToStringOrDash()</td>
@if (string.IsNullOrWhiteSpace(_client.JwtBearerGrantAccessTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.JwtBearerGrantAccessTokenLifespan</td>
}
</tr>
</tbody>
</table>
Expand All @@ -319,12 +391,30 @@ else
</thead>
<tbody>
<tr>
<td>ID Token</td>
<td>@_client.ImplicitGrantIdTokenLifespan.ToStringOrDash()</td>
<td>Access Token</td>
@if (string.IsNullOrWhiteSpace(_client.ImplicitGrantAccessTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.ImplicitGrantAccessTokenLifespan</td>
}
</tr>
<tr>
<td>Access Token</td>
<td>@_client.ImplicitGrantAccessTokenLifespan.ToStringOrDash()</td>
<td>ID Token</td>
@if (string.IsNullOrWhiteSpace(_client.ImplicitGrantIdTokenLifespan))
{
<td>
<p class="is-italic is-color-grey">hydra default value</p>
</td>
}
else
{
<td>@_client.ImplicitGrantIdTokenLifespan</td>
}
</tr>
</tbody>
</table>
Expand Down
5 changes: 4 additions & 1 deletion ory/hydra/hydra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ oidc:
- pairwise
- public
pairwise:
salt: youReallyNeedToChangeThis
salt: youReallyNeedToChangeThis

ttl:
refresh_token: -1

0 comments on commit ce69e35

Please sign in to comment.