Skip to content

Commit

Permalink
Antiforgery for profile pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Jan 28, 2023
1 parent 6ea95a6 commit 2da3c41
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 3 deletions.
Expand Up @@ -19,6 +19,7 @@

namespace Squidex.Areas.IdentityServer.Controllers.Account;

[AutoValidateAntiforgeryToken]
public sealed class AccountController : IdentityServerController
{
private readonly IUserService userService;
Expand Down
Expand Up @@ -25,6 +25,7 @@
namespace Squidex.Areas.IdentityServer.Controllers.Profile;

[Authorize]
[AutoValidateAntiforgeryToken]
public sealed class ProfileController : IdentityServerController
{
private readonly IUserPictureStore userPictureStore;
Expand Down
Expand Up @@ -21,6 +21,7 @@

namespace Squidex.Areas.IdentityServer.Controllers.Setup;

[AutoValidateAntiforgeryToken]
public class SetupController : IdentityServerController
{
private readonly IAssetStore assetStore;
Expand Down
Expand Up @@ -12,6 +12,8 @@
}

<form asp-controller="Account" asp-action="Consent" asp-route-returnurl="@Model!.ReturnUrl" method="post">
@Html.AntiForgeryToken()

<h2>@T.Get("users.consent.headline")</h2>

<label for="consentToAutomatedEmails">
Expand Down
Expand Up @@ -31,6 +31,8 @@
</div>

<form asp-controller="Account" asp-action="External" asp-route-returnurl="@Model!.ReturnUrl" method="post">
@Html.AntiForgeryToken()

@foreach (var provider in Model!.ExternalProviders)
{
var schema = provider.AuthenticationScheme.ToLowerInvariant();
Expand Down Expand Up @@ -60,6 +62,8 @@
}

<form asp-controller="Account" asp-action="Login" asp-route-returnurl="@Model!.ReturnUrl" method="post">
@Html.AntiForgeryToken()

<div class="form-group">
<input type="email" class="form-control" name="email" id="email" placeholder="@T.Get("users.login.emailPlaceholder")" />
</div>
Expand Down
Expand Up @@ -38,6 +38,8 @@
</div>
<div class="col">
<form id="pictureForm" class="profile-picture-form" asp-controller="Profile" asp-action="UploadPicture" method="post" enctype="multipart/form-data">
@Html.AntiForgeryToken()

<span class="btn btn-secondary" id="pictureButton">
<span>@T.Get("users.profile.uploadPicture")</span>

Expand All @@ -48,6 +50,8 @@
</div>

<form class="profile-form profile-section" asp-controller="Profile" asp-action="UpdateProfile" method="post">
@Html.AntiForgeryToken()

<div class="form-group">
<label for="email">@T.Get("common.email")</label>

Expand Down Expand Up @@ -101,6 +105,8 @@
@if (Model!.ExternalLogins.Count > 1 || Model!.HasPassword)
{
<form asp-controller="Profile" asp-action="RemoveLogin" method="post">
@Html.AntiForgeryToken()

<input type="hidden" value="@login.LoginProvider" name="LoginProvider" />
<input type="hidden" value="@login.ProviderKey" name="ProviderKey" />

Expand All @@ -115,6 +121,8 @@
</table>

<form asp-controller="Profile" asp-action="AddLogin" method="post">
@Html.AntiForgeryToken()

@foreach (var provider in Model!.ExternalProviders.Where(x => Model!.ExternalLogins.All(y => x.AuthenticationScheme != y.LoginProvider)))
{
var schema = provider.AuthenticationScheme.ToLowerInvariant();
Expand All @@ -134,9 +142,11 @@
<div class="profile-section">
<h2>@T.Get("users.profile.passwordTitle")</h2>

@if (Model!.HasPassword)
@if (Model!.HasPassword)
{
<form class="profile-form" asp-controller="Profile" asp-action="ChangePassword" method="post">
@Html.AntiForgeryToken()

<div class="form-group">
<label for="oldPassword">@T.Get("common.oldPassword")</label>

Expand Down Expand Up @@ -169,6 +179,8 @@
else
{
<form class="profile-form" asp-controller="Profile" asp-action="SetPassword" method="post">
@Html.AntiForgeryToken()

<div class="form-group">
<label for="password">@T.Get("common.password")</label>

Expand Down Expand Up @@ -217,6 +229,8 @@
<label for="generate">&nbsp;</label>

<form class="profile-form" asp-controller="Profile" asp-action="GenerateClientSecret" method="post">
@Html.AntiForgeryToken()

<button type="submit" class="btn btn-success btn-block" id="generate">@T.Get("users.profile.generateClient")</button>
</form>
</div>
Expand All @@ -231,6 +245,8 @@
<small class="form-text text-muted mt-2 mb-2">@T.Get("users.profile.propertiesHint")</small>

<form class="profile-form" asp-controller="Profile" asp-action="UpdateProperties" method="post">
@Html.AntiForgeryToken()

<div class="mb-2" id="properties">
@for (var i = 0; i < Model!.Properties.Count; i++)
{
Expand Down
Expand Up @@ -160,6 +160,8 @@
}

<form class="profile-form" asp-controller="Setup" asp-action="Setup" method="post">
@Html.AntiForgeryToken()

<div class="form-group">
<label for="email">@T.Get("common.email")</label>

Expand Down
Expand Up @@ -36,7 +36,7 @@ export function getCellWidth(field: TableField, sizes: FieldSizes | undefined |
case META_FIELDS.statusNext:
return 240;
case META_FIELDS.statusColor:
return 50;
return 80;
case META_FIELDS.version:
return 80;
default:
Expand Down
Expand Up @@ -82,7 +82,7 @@
</ng-container>
<ng-container *ngSwitchCase="metaFields.statusColor">
<ng-container *ngIf="content.newStatus; else singleStatus">
<span class="text-nowrap">
<span class="text-nowrap truncate">
<sqx-content-status
[status]="content.status"
[statusColor]="content.statusColor">
Expand Down

0 comments on commit 2da3c41

Please sign in to comment.