Skip to content

Commit

Permalink
Run dotnet format (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton authored Dec 16, 2021
1 parent 61dc65a commit 23b0a1f
Show file tree
Hide file tree
Showing 531 changed files with 2,982 additions and 2,958 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.sh eol=lf
*.cs eol=lf
.dockerignore eol=lf
dockerfile eol=lf
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ jobs:
run: dotnet tool restore
shell: pwsh

# - name: Verify Format
# run: dotnet tool run dotnet-format --check
# shell: pwsh
- name: Verify Format
run: dotnet tool run dotnet-format --check
shell: pwsh

- name: Test OSS solution
run: dotnet test ./test --configuration Debug --no-build
Expand Down
54 changes: 27 additions & 27 deletions bitwarden_license/src/Sso/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
using Bit.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Enums;
using Bit.Core.Models;
using Bit.Core.Models.Api;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Sso.Models;
using Bit.Sso.Utilities;
using IdentityModel;
Expand All @@ -11,20 +21,10 @@
using IdentityServer4.Services;
using IdentityServer4.Stores;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Bit.Core.Models;
using Bit.Core.Models.Api;
using Bit.Core.Utilities;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
using Microsoft.Extensions.Logging;

namespace Bit.Sso.Controllers
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public AccountController(
_eventService = eventService;
_globalSettings = globalSettings;
}

[HttpGet]
public async Task<IActionResult> PreValidate(string domainHint)
{
Expand Down Expand Up @@ -382,7 +382,7 @@ private async Task<User> AutoProvisionUserAsync(string provider, string provider
{
email = providerUserId;
}

if (!Guid.TryParse(provider, out var orgId))
{
// TODO: support non-org (server-wide) SSO in the future?
Expand Down Expand Up @@ -432,7 +432,7 @@ private async Task<User> AutoProvisionUserAsync(string provider, string provider
{
throw new Exception(_i18nService.T("CouldNotFindOrganization", orgId));
}

// Try to find OrgUser via existing User Id (accepted/confirmed user)
if (existingUser != null)
{
Expand All @@ -442,7 +442,7 @@ private async Task<User> AutoProvisionUserAsync(string provider, string provider

// If no Org User found by Existing User Id - search all organization users via email
orgUser ??= await _organizationUserRepository.GetByOrganizationEmailAsync(orgId, email);

// All Existing User flows handled below
if (existingUser != null)
{
Expand All @@ -457,11 +457,11 @@ private async Task<User> AutoProvisionUserAsync(string provider, string provider
// Org User is not created - no invite has been sent
throw new Exception(_i18nService.T("UserAlreadyExistsInviteProcess"));
}

if (orgUser.Status == OrganizationUserStatusType.Invited)
{
// Org User is invited - they must manually accept the invite via email and authenticate with MP
throw new Exception(_i18nService.T("UserAlreadyInvited", email, organization.Name));
throw new Exception(_i18nService.T("UserAlreadyInvited", email, organization.Name));
}

// Accepted or Confirmed - create SSO link and return;
Expand Down Expand Up @@ -507,7 +507,7 @@ private async Task<User> AutoProvisionUserAsync(string provider, string provider
ApiKey = CoreHelpers.SecureRandomString(30)
};
await _userService.RegisterUserAsync(user);

// If the organization has 2fa policy enabled, make sure to default jit user 2fa to email
var twoFactorPolicy =
await _policyRepository.GetByOrganizationIdTypeAsync(orgId, PolicyType.TwoFactorAuthentication);
Expand All @@ -516,14 +516,14 @@ private async Task<User> AutoProvisionUserAsync(string provider, string provider
user.SetTwoFactorProviders(new Dictionary<TwoFactorProviderType, TwoFactorProvider>
{
[TwoFactorProviderType.Email] = new TwoFactorProvider
{
MetaData = new Dictionary<string, object> { ["Email"] = user.Email.ToLowerInvariant() },
Enabled = true
}
{
MetaData = new Dictionary<string, object> { ["Email"] = user.Email.ToLowerInvariant() },
Enabled = true
}
});
await _userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.Email);
}

// Create Org User if null or else update existing Org User
if (orgUser == null)
{
Expand All @@ -541,10 +541,10 @@ private async Task<User> AutoProvisionUserAsync(string provider, string provider
orgUser.UserId = user.Id;
await _organizationUserRepository.ReplaceAsync(orgUser);
}

// Create sso user record
await CreateSsoUserRecord(providerUserId, user.Id, orgId, orgUser);

return user;
}

Expand Down
8 changes: 4 additions & 4 deletions bitwarden_license/src/Sso/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using IdentityServer4.Services;
using System.Diagnostics;
using System.Threading.Tasks;
using Bit.Sso.Models;
using System.Diagnostics;
using IdentityServer4.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;

namespace Bit.Sso.Controllers
{
Expand Down
4 changes: 2 additions & 2 deletions bitwarden_license/src/Sso/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;

namespace Bit.Sso.Controllers
{
Expand All @@ -12,7 +12,7 @@ public DateTime GetAlive()
{
return DateTime.UtcNow;
}

[HttpGet("~/version")]
public JsonResult GetVersion()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Sso.Models;
using Bit.Sso.Utilities;
using IdentityModel;
Expand Down Expand Up @@ -136,7 +136,7 @@ public override async Task<IEnumerable<AuthenticationScheme>> GetRequestHandlerS

await LoadAllDynamicSchemesIntoCacheAsync();
schemes.AddRange(_handlerSchemesCopy);

return schemes.ToArray();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Options;
using System;
using System;
using System.Collections.Concurrent;
using Microsoft.Extensions.Options;

namespace Bit.Sso.Utilities
{
Expand Down Expand Up @@ -35,4 +35,4 @@ public bool TryRemove(string name)
return _cache.TryRemove(name ?? Options.DefaultName, out _);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public interface IExtendedOptionsMonitorCache<TOptions> : IOptionsMonitorCache<T
{
void AddOrUpdate(string name, TOptions options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Collections.Generic;
using Bit.Core.Business.Sso;
using Bit.Core.IdentityServer;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Sso.Models;
using IdentityServer4.Models;
using IdentityServer4.ResponseHandling;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Bit.Sso.Utilities
public class SsoAuthenticationMiddleware
{
private readonly RequestDelegate _next;

public SsoAuthenticationMiddleware(RequestDelegate next, IAuthenticationSchemeProvider schemes)
{
_next = next ?? throw new ArgumentNullException(nameof(next));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ProviderUser(ProviderUserStatusType status, ProviderUserType type)
Status = status;
Type = type;
}

public void Customize(IFixture fixture)
{
fixture.Customize<Core.Models.Table.Provider.ProviderUser>(composer => composer
Expand Down
Loading

0 comments on commit 23b0a1f

Please sign in to comment.