Browse Source

Cleanup

pull/169/head
Sebastian Stehle 9 years ago
parent
commit
b3736c1ed2
  1. 2
      src/Squidex/Areas/Api/Controllers/ApiController.cs
  2. 11
      src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs
  3. 4
      src/Squidex/Areas/IdentityServer/Config/LazyClientStore.cs
  4. 5
      src/Squidex/Areas/IdentityServer/Controllers/Extensions.cs
  5. 2
      src/Squidex/Areas/IdentityServer/Controllers/IdentityServerController.cs
  6. 4
      src/Squidex/Areas/IdentityServer/Startup.cs
  7. 2
      src/Squidex/Areas/Portal/Middlewares/PortalRedirectMiddleware.cs
  8. 4
      src/Squidex/Config/Authentication/AuthenticationServices.cs
  9. 4
      src/Squidex/Config/Constants.cs
  10. 2
      src/Squidex/Pipeline/Swagger/SwaggerHelper.cs

2
src/Squidex/Areas/Api/Controllers/ApiController.cs

@ -51,7 +51,7 @@ namespace Squidex.Areas.Api.Controllers
{ {
if (!context.HttpContext.Request.PathBase.StartsWithSegments("/api")) if (!context.HttpContext.Request.PathBase.StartsWithSegments("/api"))
{ {
context.Result = new NotFoundResult(); context.Result = new RedirectResult("/");
} }
} }
} }

11
src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs

@ -13,9 +13,11 @@ using IdentityModel;
using IdentityServer4.Models; using IdentityServer4.Models;
using IdentityServer4.Stores; using IdentityServer4.Stores;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.AspNetCore.DataProtection.Repositories; using Microsoft.AspNetCore.DataProtection.Repositories;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Squidex.Config; using Squidex.Config;
using Squidex.Domain.Users; using Squidex.Domain.Users;
using Squidex.Domain.Users.DataProtection.Orleans; using Squidex.Domain.Users.DataProtection.Orleans;
@ -47,6 +49,15 @@ namespace Squidex.Areas.IdentityServer.Config
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
services.AddDataProtection().SetApplicationName("Squidex"); services.AddDataProtection().SetApplicationName("Squidex");
services.AddSingleton<OrleansXmlRepository>();
services.AddSingleton<IConfigureOptions<KeyManagementOptions>>(s =>
{
return new ConfigureOptions<KeyManagementOptions>(options =>
{
options.XmlRepository = s.GetRequiredService<OrleansXmlRepository>();
});
});
services.AddSingleton(GetApiResources()); services.AddSingleton(GetApiResources());
services.AddSingleton(GetIdentityResources()); services.AddSingleton(GetIdentityResources());

4
src/Squidex/Areas/IdentityServer/Config/LazyClientStore.cs

@ -131,8 +131,8 @@ namespace Squidex.Areas.IdentityServer.Config
ClientSecrets = new List<Secret> { new Secret(Constants.InternalClientSecret) }, ClientSecrets = new List<Secret> { new Secret(Constants.InternalClientSecret) },
RedirectUris = new List<string> RedirectUris = new List<string>
{ {
urlsOptions.BuildUrl("orleans/signin-oidc", false), urlsOptions.BuildUrl($"{Constants.PortalPrefix}/signin-oidc", false),
urlsOptions.BuildUrl("portal/signin-oidc", false) urlsOptions.BuildUrl($"{Constants.OrleansPrefix}/signin-oidc", false)
}, },
AccessTokenLifetime = (int)TimeSpan.FromDays(30).TotalSeconds, AccessTokenLifetime = (int)TimeSpan.FromDays(30).TotalSeconds,
AllowedGrantTypes = GrantTypes.ImplicitAndClientCredentials, AllowedGrantTypes = GrantTypes.ImplicitAndClientCredentials,

5
src/Squidex/Areas/IdentityServer/Controllers/Extensions.cs

@ -10,7 +10,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Squidex.Shared.Users; using Squidex.Shared.Users;
@ -31,8 +31,7 @@ namespace Squidex.Areas.IdentityServer.Controllers
{ {
var externalSchemes = await signInManager.GetExternalAuthenticationSchemesAsync(); var externalSchemes = await signInManager.GetExternalAuthenticationSchemesAsync();
var externalProviders = var externalProviders =
externalSchemes externalSchemes.Where(x => x.Name != OpenIdConnectDefaults.AuthenticationScheme)
.Where(x => x.Name != CookieAuthenticationDefaults.AuthenticationScheme)
.Select(x => new ExternalProvider(x.Name, x.DisplayName)).ToList(); .Select(x => new ExternalProvider(x.Name, x.DisplayName)).ToList();
return externalProviders; return externalProviders;

2
src/Squidex/Areas/IdentityServer/Controllers/IdentityServerController.cs

@ -18,7 +18,7 @@ namespace Squidex.Areas.IdentityServer.Controllers
{ {
if (!context.HttpContext.Request.PathBase.StartsWithSegments("/identity-server")) if (!context.HttpContext.Request.PathBase.StartsWithSegments("/identity-server"))
{ {
context.Result = new RedirectResult("/"); context.Result = new NotFoundResult();
} }
} }
} }

4
src/Squidex/Areas/IdentityServer/Startup.cs

@ -23,9 +23,9 @@ namespace Squidex.Areas.IdentityServer
var environment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>(); var environment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
app.Map(Constants.IdentityPrefix, identityApp => app.Map(Constants.IdentityServerPrefix, identityApp =>
{ {
app.UseMyIdentityServer(); identityApp.UseMyIdentityServer();
if (environment.IsDevelopment()) if (environment.IsDevelopment())
{ {

2
src/Squidex/Areas/Portal/Middlewares/PortalRedirectMiddleware.cs

@ -17,7 +17,7 @@ namespace Squidex.Areas.Portal.Middlewares
{ {
private readonly IAppPlanBillingManager appPlansBillingManager; private readonly IAppPlanBillingManager appPlansBillingManager;
public PortalRedirectMiddleware(IAppPlanBillingManager appPlansBillingManager) public PortalRedirectMiddleware(RequestDelegate next, IAppPlanBillingManager appPlansBillingManager)
{ {
this.appPlansBillingManager = appPlansBillingManager; this.appPlansBillingManager = appPlansBillingManager;
} }

4
src/Squidex/Config/Authentication/AuthenticationServices.cs

@ -40,11 +40,11 @@ namespace Squidex.Config.Authentication
if (!string.IsNullOrWhiteSpace(identityOptions.AuthorityUrl)) if (!string.IsNullOrWhiteSpace(identityOptions.AuthorityUrl))
{ {
apiAuthorityUrl = identityOptions.AuthorityUrl.BuildFullUrl(Constants.IdentityPrefix); apiAuthorityUrl = identityOptions.AuthorityUrl.BuildFullUrl(Constants.IdentityServerPrefix);
} }
else else
{ {
apiAuthorityUrl = urlsOptions.BuildUrl(Constants.IdentityPrefix); apiAuthorityUrl = urlsOptions.BuildUrl(Constants.IdentityServerPrefix);
} }
authBuilder.AddIdentityServerAuthentication(options => authBuilder.AddIdentityServerAuthentication(options =>

4
src/Squidex/Config/Constants.cs

@ -18,7 +18,7 @@ namespace Squidex.Config
public static readonly string ApiScope = "squidex-api"; public static readonly string ApiScope = "squidex-api";
public static readonly string PortalPrefix = "/prefix"; public static readonly string PortalPrefix = "/portal";
public static readonly string OrleansPrefix = "/orleans"; public static readonly string OrleansPrefix = "/orleans";
@ -32,6 +32,6 @@ namespace Squidex.Config
public static readonly string InternalClientSecret = "squidex-internal".Sha256(); public static readonly string InternalClientSecret = "squidex-internal".Sha256();
public static readonly string IdentityPrefix = "/identity-server"; public static readonly string IdentityServerPrefix = "/identity-server";
} }
} }

2
src/Squidex/Pipeline/Swagger/SwaggerHelper.cs

@ -80,7 +80,7 @@ namespace Squidex.Pipeline.Swagger
public static SwaggerSecurityScheme CreateOAuthSchema(MyUrlsOptions urlOptions) public static SwaggerSecurityScheme CreateOAuthSchema(MyUrlsOptions urlOptions)
{ {
var tokenUrl = urlOptions.BuildUrl($"{Constants.IdentityPrefix}/connect/token"); var tokenUrl = urlOptions.BuildUrl($"{Constants.IdentityServerPrefix}/connect/token");
var securityDocs = LoadDocs("security"); var securityDocs = LoadDocs("security");
var securityText = securityDocs.Replace("<TOKEN_URL>", tokenUrl); var securityText = securityDocs.Replace("<TOKEN_URL>", tokenUrl);

Loading…
Cancel
Save