hi, I have a dotnetcore2.1 project with IdentityServer4 and it works. But when I migrate from 2.1 to 2.2 doesn't work and tokenClient.RequestClientCredentialsAsync AccessToken return null. Why?
Check your logs.
2019-01-28 12:31:44 192.168.4.73 GET / - 443 - 192.168.4.73 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/64.0.3282.140+Safari/537.36+Edge/17.17134 - 200 0 0 1416
2019-01-28 12:31:58 192.168.4.73 GET /api/identity/isloggedin - 443 - 192.168.4.73 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/64.0.3282.140+Safari/537.36+Edge/17.17134 https://sviluppo.krono.com/ 200 0 0 430
2019-01-28 12:31:58 192.168.4.73 GET /api/config/getapplicationbuild - 443 - 192.168.4.73 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/64.0.3282.140+Safari/537.36+Edge/17.17134 https://sviluppo.krono.com/login-adm 200 0 0 19
Startup client
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.IO;
using Microsoft.IdentityModel.Tokens;
using Microsoft.AspNetCore.Authorization;
using Newtonsoft.Json;
using KSM.Database.AppDB.Models;
using KSM.IdentityProvider.Interface;
using KSM.IdentityProvider;
using Microsoft.AspNetCore.Mvc.Authorization;
using KSM.Web.Helpers;
using System.Security.Claims;
using Microsoft.AspNetCore.Http.Features;
using System;
using KSM.AuditProvider;
using Microsoft.Extensions.FileProviders;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace KSM.Web
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.Configure<KSMConfiguration>(Configuration.GetSection("Configuration"));
services.AddTransient<IKSMIdentityProvider, KSMIdentityProvider>();
services.AddTransient<KSMAuditProvider>();
//***************************************************************************************************
//ADDED ALX
services.AddCors(options =>
{
options.AddPolicy("AllowAll", p =>
{
//p.AllowCredentials();
p.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
services.AddMvc(options => options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build())))
.AddJsonOptions(options =>
{
options.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Include;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});
services.AddAuthorization(options =>
{
options.AddPolicy("SINGLESESSION", policy =>
{
policy.Requirements.Add(new SingleSessionRequirement());
});
options.AddPolicy("CORPORATE", policyBuilder =>
{
policyBuilder.RequireAuthenticatedUser()
.RequireAssertion(context => context.User.HasClaim(ClaimTypes.Role, "CORPORATE"))
.Build();
});
options.AddPolicy("INSTALLER", policyBuilder =>
{
policyBuilder.RequireAuthenticatedUser()
.RequireAssertion(context => context.User.HasClaim(ClaimTypes.Role, "INSTALLER"))
.Build();
});
options.AddPolicy("OPERATOR", policyBuilder =>
{
policyBuilder.RequireAuthenticatedUser()
.RequireAssertion(context => context.User.HasClaim(ClaimTypes.Role, "OPERATOR"))
.Build();
});
options.AddPolicy("SYSTEMUSER", policyBuilder =>
{
policyBuilder.RequireAuthenticatedUser()
.RequireAssertion(context => context.User.HasClaim(ClaimTypes.Role, "SYSTEMUSER"))
.Build();
});
options.AddPolicy("SUPERUSER", policyBuilder =>
{
policyBuilder.RequireAuthenticatedUser()
.RequireAssertion(context => context.User.HasClaim(ClaimTypes.Role, "SUPERUSER"))
.Build();
});
});
KSMConfiguration configuration = new KSMConfiguration();
Configuration.GetSection("Configuration").Bind(configuration);
services.Configure<FormOptions>(options =>
{
options.MemoryBufferThreshold = Int32.MaxValue;
options.MultipartBodyLengthLimit = Int32.MaxValue;
});
string connectionString = Configuration.GetConnectionString("DefaultConnection");
//services.AddDbContext<DBPLATFORMContext>(options => options.UseSqlServer(connectionString));
services.AddDbContext<DBPLATFORMContext>(options =>
{
options.UseSqlServer(connectionString,
sqlServerOptionsAction: sqlOptions =>
{
sqlOptions.EnableRetryOnFailure(maxRetryCount: 5,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
});
});
services.AddAuthentication(KSMAuthenticationHelper.CookieSchema)
.AddCookie(KSMAuthenticationHelper.CookieSchema, options =>
{
options.AccessDeniedPath = "/Login";
options.SlidingExpiration = true;
options.LoginPath = "/Login";
})
.AddJwtBearer("KSMApi", options =>
{
options.Authority = configuration.AuthorityHostURL;
options.Audience = "KSMApi";
options.RequireHttpsMetadata = true;
//options.RequireHttpsMetadata = false;
//options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidAudience = "KSMApi"
};
options.BackchannelHttpHandler = new KSMHttpClientHandler(configuration.ProxyActive, configuration.ProxyHost, configuration.ProxyPort, configuration.ProxyUsername, configuration.ProxyPassword);
});
services.AddSingleton<IAuthorizationHandler, SingleSessionHandler>();
//services.AddLogging(builder => builder.AddConsole());
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDeveloperExceptionPage();
// app.UseBrowserLink();
app.UseDatabaseErrorPage();
app.Use(async (context, next) => {
await next();
if (context.Response.StatusCode == 404 &&
!Path.HasExtension(context.Request.Path.Value) &&
!context.Request.Path.Value.StartsWith("/api/"))
{
context.Request.Path = "/index.html";
await next();
}
});
//************************
app.UseHsts();
app.UseHttpsRedirection();
app.UseCookiePolicy();
//********************************
app.UseDefaultFiles();
app.UseAuthentication();
app.UseStaticFiles();
app.UseCors("AllowAll");
app.UseMvcWithDefaultRoute();
}
}
}
The IdentityServer logs - not IIS.
Posting the code will not help.
program client
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.AspNetCore;
namespace KSM.Web
{
public class Program
{
public static void Main(string[] args)
{
// BuildWebHost(args).Run();
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.CaptureStartupErrors(true)
.UseSetting("detailedErrors", "true")
.UseStartup<Startup>()
.ConfigureAppConfiguration((hostContext, config) =>
{
var env = hostContext.HostingEnvironment;
config.Sources.Clear();
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false);
config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
config.AddEnvironmentVariables();
});
}
}
startup identity server
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
using KSM.AuthProvider.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using Microsoft.Extensions.Logging;
namespace KSM.AuthProvider
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Cls_Log.Log("CONFIGURATION");
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
Cls_Log.Log("ConfigureServices1");
try
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
string connectionString = Configuration.GetConnectionString("DefaultConnection");
services.AddIdentityServer()
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = builder =>
builder.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
})
.AddOperationalStore(options =>
{
options.ConfigureDbContext = builder =>
builder.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
options.EnableTokenCleanup = true;
options.TokenCleanupInterval = 30;
});
services.AddAuthentication("KSMWeb")
.AddCookie("KSMWeb", options =>
{
options.Cookie.Name = "KSMWeb";
})
;
Cls_Log.Log("ConfigureServices3");
}catch(Exception ex)
{
Cls_Log.Log("ConfigureServices3" + ex.Message);
}
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
try
{
Cls_Log.Log("Configure");
Microsoft.AspNetCore.Builder.IApplicationBuilder app1;
Database.InitializeDatabase(app);
app.UseHsts();
app.UseHttpsRedirection();
app.UseDeveloperExceptionPage();
// app.UseHttpsRedirection();
app.UseCookiePolicy();
app.UseIdentityServer();
app.UseAuthentication();
}catch(Exception ex)
{
Cls_Log.Log("Configure" + ex.Message);
}
}
}
}
program indentity
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using KSM.AuthProvider.Data;
//using Microsoft.AspNetCore.Hosting.Internal;
//using Microsoft.AspNetCore.Hosting.Internal;
namespace KSM.AuthProvider
{
public class Program
{
public static void Main(string[] args)
{
//var host = BuildWebHost(args);
//host.Run();
CreateWebHostBuilder(args).Build().Run();
Cls_Log.Log("ddddddd");
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.CaptureStartupErrors(true)
.UseSetting("detailedErrors", "true")
.UseStartup<Startup>()
.ConfigureAppConfiguration((hostContext, config) =>
{
var env = hostContext.HostingEnvironment;
config.Sources.Clear();
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false);
config.AddJsonFile(
$"appsettings.{env.EnvironmentName}.json",
optional: true, reloadOnChange: true);
config.AddEnvironmentVariables();
});
}
}
config.cs indentity
using IdentityModel;
using IdentityServer4;
using IdentityServer4.Models;
using IdentityServer4.Test;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace KSM.AuthProvider
{
public class KSMConfig
{
// scopes define the API resources in your system
public static IEnumerable
{
Cls_Log.Log("sono qui");
return new List
new ApiResource {
Name = "KSMApi",
DisplayName = "KSM API",
Description = "KSM API Access",
ApiSecrets = new List
Scopes = new List
new Scope("KSMApi.Read"),
new Scope("KSMApi.Write")
},
}
};
}
// client want to access resources (aka scopes)
public static IEnumerable<Client> GetClients()
{
Cls_Log.Log("sono qui2");
return new List<Client>
{
new Client
{
ClientId = "KSMWeb",
AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowedScopes =
{
"KSMApi.Read",
"KSMApi.Write"
}
}
};
}
public static IEnumerable<IdentityResource> GetResources()
{
try
{
Cls_Log.Log("sono qui3");
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email()
};
}catch(Exception ex)
{
Cls_Log.Log(ex.Message);
return null;
}
}
}
}
in debug Token.Error= Internal Server Error 500 only if I use .netcore2.2
client file
<UserSecretsId>aspnet-KSM.Web-64fd9de1-b149-45c0-a580-e72a89825f40</UserSecretsId>
<AssemblyName>KSM.Web</AssemblyName>
<RootNamespace>KSM.Web</RootNamespace>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsTransformWebConfigDisabled>false</IsTransformWebConfigDisabled>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<UseNETCoreGenerator>true</UseNETCoreGenerator>
<!--<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />-->
identityserver
2019-01-28 14:33:12.116 +01:00 [WRN] Using an in-memory repository. Keys will not be persisted to storage.
2019-01-28 14:33:12.139 +01:00 [WRN] Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
2019-01-28 14:33:12.151 +01:00 [WRN] No XML encryptor configured. Key "79fabd19-7d68-4e08-8054-93b71e38d038" may be persisted to storage in unencrypted form.
2019-01-28 14:33:12.663 +01:00 [INF] Starting IdentityServer4 version 2.3.2.0
2019-01-28 14:33:12.684 +01:00 [INF] Using the default authentication scheme KSMWeb for IdentityServer
2019-01-28 14:33:12.684 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for authentication
2019-01-28 14:33:12.684 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for sign-in
2019-01-28 14:33:12.684 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for sign-out
2019-01-28 14:33:12.684 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for challenge
2019-01-28 14:33:12.684 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for forbid
2019-01-28 14:33:12.699 +01:00 [DBG] Starting grant removal
2019-01-28 14:33:12.741 +01:00 [DBG] Login Url: /Account/Login
2019-01-28 14:33:12.743 +01:00 [DBG] Login Return Url Parameter: ReturnUrl
2019-01-28 14:33:12.743 +01:00 [DBG] Logout Url: /Account/Logout
2019-01-28 14:33:12.743 +01:00 [DBG] ConsentUrl Url: /consent
2019-01-28 14:33:12.743 +01:00 [DBG] Consent Return Url Parameter: returnUrl
2019-01-28 14:33:12.743 +01:00 [DBG] Error Url: /home/error
2019-01-28 14:33:12.743 +01:00 [DBG] Error Id Parameter: errorId
2019-01-28 14:33:12.765 +01:00 [DBG] Request path /connect/token matched to endpoint type Token
2019-01-28 14:33:12.774 +01:00 [DBG] Endpoint enabled: Token, successfully created handler: IdentityServer4.Endpoints.TokenEndpoint
2019-01-28 14:33:12.774 +01:00 [INF] Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
2019-01-28 14:33:12.782 +01:00 [DBG] Start token request.
2019-01-28 14:33:12.788 +01:00 [DBG] Start client validation
2019-01-28 14:33:12.793 +01:00 [DBG] Start parsing Basic Authentication secret
2019-01-28 14:33:12.793 +01:00 [DBG] Parser found secret: BasicAuthenticationSecretParser
2019-01-28 14:33:12.793 +01:00 [DBG] Secret id found: KSMWeb
2019-01-28 14:33:12.938 +01:00 [ERR] Failed executing DbCommand (2ms) [Parameters=[@__clientId_0='?' (Size = 200)], CommandType='"Text"', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[AbsoluteRefreshTokenLifetime], [x].[AccessTokenLifetime], [x].[AccessTokenType], [x].[AllowAccessTokensViaBrowser], [x].[AllowOfflineAccess], [x].[AllowPlainTextPkce], [x].[AllowRememberConsent], [x].[AlwaysIncludeUserClaimsInIdToken], [x].[AlwaysSendClientClaims], [x].[AuthorizationCodeLifetime], [x].[BackChannelLogoutSessionRequired], [x].[BackChannelLogoutUri], [x].[ClientClaimsPrefix], [x].[ClientId], [x].[ClientName], [x].[ClientUri], [x].[ConsentLifetime], [x].[Created], [x].[Description], [x].[DeviceCodeLifetime], [x].[EnableLocalLogin], [x].[Enabled], [x].[FrontChannelLogoutSessionRequired], [x].[FrontChannelLogoutUri], [x].[IdentityTokenLifetime], [x].[IncludeJwtId], [x].[LastAccessed], [x].[LogoUri], [x].[NonEditable], [x].[PairWiseSubjectSalt], [x].[ProtocolType], [x].[RefreshTokenExpiration], [x].[RefreshTokenUsage], [x].[RequireClientSecret], [x].[RequireConsent], [x].[RequirePkce], [x].[SlidingRefreshTokenLifetime], [x].[UpdateAccessTokenClaimsOnRefresh], [x].[Updated], [x].[UserCodeType], [x].[UserSsoLifetime]
FROM [Clients] AS [x]
WHERE [x].[ClientId] = @__clientId_0
ORDER BY [x].[Id]
System.Data.SqlClient.SqlException (0x80131904): Il nome di colonna 'Created' non รจ valido.
Il nome di colonna 'DeviceCodeLifetime' non รจ valido.
Il nome di colonna 'LastAccessed' non รจ valido.
Il nome di colonna 'NonEditable' non รจ valido.
Il nome di colonna 'Updated' non รจ valido.
Il nome di colonna 'UserCodeType' non รจ valido.
Il nome di colonna 'UserSsoLifetime' non รจ valido.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
ClientConnectionId:1a92c9be-fe3a-4575-a240-a2b7175a5ea8
Error Number:207,State:1,Class:16
2019-01-28 14:33:12.959 +01:00 [ERR] An exception occurred while iterating over the results of a query for context type 'IdentityServer4.EntityFramework.DbContexts.ConfigurationDbContext'.
System.Data.SqlClient.SqlException (0x80131904): Il nome di colonna 'Created' non รจ valido.
Il nome di colonna 'DeviceCodeLifetime' non รจ valido.
Il nome di colonna 'LastAccessed' non รจ valido.
Il nome di colonna 'NonEditable' non รจ valido.
Il nome di colonna 'Updated' non รจ valido.
Il nome di colonna 'UserCodeType' non รจ valido.
Il nome di colonna 'UserSsoLifetime' non รจ valido.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteTState,TResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.TryGetFirstTSource
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found)
at lambda_method(Closure )
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable1.GetEnumerator()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext()
ClientConnectionId:1a92c9be-fe3a-4575-a240-a2b7175a5ea8
Error Number:207,State:1,Class:16
2019-01-28 14:33:12.960 +01:00 [ERR] An exception occurred while iterating over the results of a query for context type 'IdentityServer4.EntityFramework.DbContexts.ConfigurationDbContext'.
System.Data.SqlClient.SqlException (0x80131904): Il nome di colonna 'Created' non รจ valido.
Il nome di colonna 'DeviceCodeLifetime' non รจ valido.
Il nome di colonna 'LastAccessed' non รจ valido.
Il nome di colonna 'NonEditable' non รจ valido.
Il nome di colonna 'Updated' non รจ valido.
Il nome di colonna 'UserCodeType' non รจ valido.
Il nome di colonna 'UserSsoLifetime' non รจ valido.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteTState,TResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.TryGetFirstTSource
at System.Linq.Enumerable.First[TSource](IEnumerable1 source)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_11.
ClientConnectionId:1a92c9be-fe3a-4575-a240-a2b7175a5ea8
Error Number:207,State:1,Class:16
System.Data.SqlClient.SqlException (0x80131904): Il nome di colonna 'Created' non รจ valido.
Il nome di colonna 'DeviceCodeLifetime' non รจ valido.
Il nome di colonna 'LastAccessed' non รจ valido.
Il nome di colonna 'NonEditable' non รจ valido.
Il nome di colonna 'Updated' non รจ valido.
Il nome di colonna 'UserCodeType' non รจ valido.
Il nome di colonna 'UserSsoLifetime' non รจ valido.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteTState,TResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.TryGetFirstTSource
at System.Linq.Enumerable.First[TSource](IEnumerable1 source)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_11.
ClientConnectionId:1a92c9be-fe3a-4575-a240-a2b7175a5ea8
Error Number:207,State:1,Class:16
2019-01-28 14:33:12.968 +01:00 [FTL] Unhandled exception: Il nome di colonna 'Created' non รจ valido.
Il nome di colonna 'DeviceCodeLifetime' non รจ valido.
Il nome di colonna 'LastAccessed' non รจ valido.
Il nome di colonna 'NonEditable' non รจ valido.
Il nome di colonna 'Updated' non รจ valido.
Il nome di colonna 'UserCodeType' non รจ valido.
Il nome di colonna 'UserSsoLifetime' non รจ valido.
System.Data.SqlClient.SqlException (0x80131904): Il nome di colonna 'Created' non รจ valido.
Il nome di colonna 'DeviceCodeLifetime' non รจ valido.
Il nome di colonna 'LastAccessed' non รจ valido.
Il nome di colonna 'NonEditable' non รจ valido.
Il nome di colonna 'Updated' non รจ valido.
Il nome di colonna 'UserCodeType' non รจ valido.
Il nome di colonna 'UserSsoLifetime' non รจ valido.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteTState,TResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.TryGetFirstTSource
at System.Linq.Enumerable.FirstTSource
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found)
at lambda_method(Closure )
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable1.GetEnumerator()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext()
at System.Linq.Enumerable.TryGetFirstTSource
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_11.<CompileQueryCore>b__0(QueryContext qc)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source, Expression1 predicate)
at IdentityServer4.EntityFramework.Stores.ClientStore.FindClientByIdAsync(String clientId)
at IdentityServer4.Stores.ValidatingClientStore1.FindClientByIdAsync(String clientId)
at IdentityServer4.Stores.IClientStoreExtensions.FindEnabledClientByIdAsync(IClientStore store, String clientId)
at IdentityServer4.Validation.ClientSecretValidator.ValidateAsync(HttpContext context)
at IdentityServer4.Endpoints.TokenEndpoint.ProcessTokenRequestAsync(HttpContext context)
at IdentityServer4.Endpoints.TokenEndpoint.ProcessAsync(HttpContext context)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
ClientConnectionId:1a92c9be-fe3a-4575-a240-a2b7175a5ea8
Error Number:207,State:1,Class:16
Are you using Entity Framework? Have you run migrations?
Yes I do
2019-01-30 08:57:38.151 +01:00 [WRN] Using an in-memory repository. Keys will not be persisted to storage.
2019-01-30 08:57:38.181 +01:00 [WRN] Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
2019-01-30 08:57:38.198 +01:00 [WRN] No XML encryptor configured. Key "b66eb79e-2b52-491b-91e5-4a8e82a5c8e9" may be persisted to storage in unencrypted form.
2019-01-30 08:57:38.870 +01:00 [INF] Starting IdentityServer4 version 2.3.2.0
2019-01-30 08:57:38.895 +01:00 [INF] Using the default authentication scheme KSMWeb for IdentityServer
2019-01-30 08:57:38.895 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for authentication
2019-01-30 08:57:38.895 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for sign-in
2019-01-30 08:57:38.895 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for sign-out
2019-01-30 08:57:38.895 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for challenge
2019-01-30 08:57:38.895 +01:00 [DBG] Using KSMWeb as default ASP.NET Core scheme for forbid
2019-01-30 08:57:38.910 +01:00 [DBG] Starting grant removal
2019-01-30 08:57:38.960 +01:00 [DBG] Login Url: /Account/Login
2019-01-30 08:57:38.961 +01:00 [DBG] Login Return Url Parameter: ReturnUrl
2019-01-30 08:57:38.961 +01:00 [DBG] Logout Url: /Account/Logout
2019-01-30 08:57:38.961 +01:00 [DBG] ConsentUrl Url: /consent
2019-01-30 08:57:38.961 +01:00 [DBG] Consent Return Url Parameter: returnUrl
2019-01-30 08:57:38.962 +01:00 [DBG] Error Url: /home/error
2019-01-30 08:57:38.962 +01:00 [DBG] Error Id Parameter: errorId
2019-01-30 08:57:38.987 +01:00 [DBG] Request path /connect/token matched to endpoint type Token
2019-01-30 08:57:38.997 +01:00 [DBG] Endpoint enabled: Token, successfully created handler: IdentityServer4.Endpoints.TokenEndpoint
2019-01-30 08:57:38.997 +01:00 [INF] Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
2019-01-30 08:57:39.007 +01:00 [DBG] Start token request.
2019-01-30 08:57:39.013 +01:00 [DBG] Start client validation
2019-01-30 08:57:39.019 +01:00 [DBG] Start parsing Basic Authentication secret
2019-01-30 08:57:39.019 +01:00 [DBG] Parser found secret: BasicAuthenticationSecretParser
2019-01-30 08:57:39.019 +01:00 [DBG] Secret id found: KSMWeb
2019-01-30 08:57:39.731 +01:00 [DBG] KSMWeb found in database: true
2019-01-30 08:57:39.735 +01:00 [ERR] Invalid client configuration for client KSMWeb: No redirect URI configured.
2019-01-30 08:57:39.738 +01:00 [ERR] No client with id 'KSMWeb' found. aborting
I have just upgraded to dotnet 2.2, and also upgraded from Idsrv 2.2.0 to 2.3.2.
I am also experiencing problems, but I have found a solution to mine.
If you check your log, you will see these two lines:
[...]
2019-01-30 08:57:38.961 +01:00 [DBG] Login Return Url Parameter: ReturnUrl
[...]
2019-01-30 08:57:38.961 +01:00 [DBG] Consent Return Url Parameter: returnUrl
[...]
Notice the difference in capitilization of the returnUrl parameter. For some reason it is now UpperCamelCase for the login redirect. Very strange, and weird.
I have updated my config accordingly:
c#
c.ServiceCollection.AddIdentityServer(options =>
{
options.UserInteraction = new UserInteractionOptions
{
LoginReturnUrlParameter = "returnUrl"
};
})
Now I can login again :)
No I haven't this AddIdentityServer ( options โฆ..
I have this one:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
using KSM.AuthProvider.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using Microsoft.Extensions.Logging;
using IdentityServer4.Configuration;
namespace KSM.AuthProvider
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Cls_Log.Log("CONFIGURATION");
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
try
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
string connectionString = Configuration.GetConnectionString("DefaultConnection");
services.AddIdentityServer(options =>
{
options.UserInteraction = new UserInteractionOptions
{
LoginReturnUrlParameter = "returnUrl"
};
})
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = builder =>
builder.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
})
.AddOperationalStore(options =>
{
options.ConfigureDbContext = builder =>
builder.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
options.EnableTokenCleanup = true;
options.TokenCleanupInterval = 30;
});
services.AddAuthentication("KSMWeb")
.AddCookie("KSMWeb", options =>
{
options.Cookie.Name = "KSMWeb";
})
;
Cls_Log.Log("ConfigureServices3");
}
catch (Exception ex)
{
Cls_Log.Log("ConfigureServices3" + ex.Message);
}
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
try
{
Cls_Log.Log("Configure");
Microsoft.AspNetCore.Builder.IApplicationBuilder app1;
Database.InitializeDatabase(app);
app.UseHsts();
app.UseHttpsRedirection();
app.UseDeveloperExceptionPage();
// app.UseHttpsRedirection();
app.UseCookiePolicy();
app.UseIdentityServer();
app.UseAuthentication();
}catch(Exception ex)
{
Cls_Log.Log("Configure" + ex.Message);
}
}
}
}
and config.cs
using IdentityModel;
using IdentityServer4;
using IdentityServer4.Models;
using IdentityServer4.Test;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace KSM.AuthProvider
{
public class KSMConfig
{
// scopes define the API resources in your system
public static IEnumerable
{
Cls_Log.Log("sono qui");
return new List
new ApiResource {
Name = "KSMApi",
DisplayName = "KSM API",
Description = "KSM API Access",
ApiSecrets = new List
Scopes = new List
new Scope("KSMApi.Read"),
new Scope("KSMApi.Write")
},
}
};
}
// client want to access resources (aka scopes)
public static IEnumerable<Client> GetClients()
{
Cls_Log.Log("sono qui2");
return new List<Client>
{
new Client
{
ClientId = "KSMWeb",
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowedScopes =
{
"KSMApi.Read",
"KSMApi.Write"
}
}
};
}
public static IEnumerable<IdentityResource> GetResources()
{
try
{
Cls_Log.Log("sono qui3");
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email()
};
}catch(Exception ex)
{
Cls_Log.Log(ex.Message);
return null;
}
}
}
}
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.