Coder Social home page Coder Social logo

identityserver / identityserver3.entityframework Goto Github PK

View Code? Open in Web Editor NEW
69.0 69.0 97.0 4.63 MB

EntityFramework persistence layer for IdentityServer3

License: Apache License 2.0

C# 65.85% Smalltalk 0.07% PowerShell 1.14% Batchfile 0.03% TSQL 32.90%

identityserver3.entityframework's People

Contributors

brockallen avatar cendter avatar fruffin avatar henrikwm avatar kendaleiv avatar leastprivilege avatar skivsoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

identityserver3.entityframework's Issues

Where is the Consent table?

when i run this application,. it's create all tables (clinet, scopes, ...) but for Consent & Token there is no table ! where dose this project store consents? i think it's not in memory because it's work fine even after restart the app.

Support for EF7 and ASP.Net Identity v3

I've successfully integrated IdentityServer3 2.0.0 beta dev into my new ASP.NET 5 application using InMemoryStore example in the awesome IdentityServer3.Samples project. Instead of hard coding the clients, scopes etc., I'd prefer to load them from SQL tables using the Factory property. I was able to use the Migrations provided in the Samples project but now I need to make it work with EF7. So, I've run the migrations using EF 6.1 and then used "dnx . ef revEng" to reverseEngineer the models into EF7. I totally understand that ASP.NET 5 is in its early stages and so is EF7. Do you have plans to support EF7? I have the same issue with ASP.NET Identity as well since the examples are using ASP.NET Identity 2.x whereas the ASP.NET 5 includes ASP.NET Identity v3. What is your recommendation to wire ASP.NET Identity v3 into IdentityServer3 2.0.0 beta dev build? I really appreciate any help or direction to make this integration working.

Question: How to Administrate?

Hi all, this is perhaps a question for @brockallen and @leastprivilege

I have been experimenting with this and it truly fits what we'd like to do. However the obvious question comes about as to how to manage the data, a web admin site would be fantastic. I see there are a couple of Admin projects for EF however these appear dead in the water, especially after trying to get them to work and after reading this issue and others:

IdentityServer/IdentityServer3.Admin#15

So I was wondering if you are aware of any admin project out there that does work? and or if there is a road map for anything like this?

If there's nothing :-( how do you both or anyone else manage the EF data in terms of doing CRUD like management for clients, claims, scopes etc etc...

"Truly appreciate" any advice you could offer ๐Ÿ‘

Entities in a seperate nuget

Hi,

I would like to suggest putting Entities in its own project/dll and publish that as a nuget which the core EF project references.

This will allow us to use the Entities separately in for example our own Entity/Model project without having to introduce Json.net/Automapper/EF as dependencies if we don't want to.

Depend core via sourcecode instead of Nuget

Depending core via sourcecode ensure consistency,avoid other nuget conflict with ilmerged core assembly.
Actually, my forked projects have already changed to sourcecode dependence

Automapper Configuration invalid

The use of Mapper.AssertConfigurationIsValid() causes a YSOD because of unmapped fields. I copied the YSOD below for what fields are unmapped. I am on the latest pre-release for all of the Thinktecture projects and I deleted all my db tables to make sure they got recreated from scratch.

Unmapped members were found. Review the types and members below.

Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type

Client -> Client (Destination member list)
Thinktecture.IdentityServer.Core.EntityFramework.Entities.Client -> Thinktecture.IdentityServer.Core.Models.Client (Destination member list)

Unmapped properties:
Claims
AlwaysSendClientClaims

PrefixClientClaims

Client -> Client (Source member list)
Thinktecture.IdentityServer.Core.Models.Client -> Thinktecture.IdentityServer.Core.EntityFramework.Entities.Client (Source member list)

Unmapped properties:
Claims
AlwaysSendClientClaims
PrefixClientClaims

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: AutoMapper.AutoMapperConfigurationException:
Unmapped members were found. Review the types and members below.

Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type

Client -> Client (Destination member list)
Thinktecture.IdentityServer.Core.EntityFramework.Entities.Client -> Thinktecture.IdentityServer.Core.Models.Client (Destination member list)

Unmapped properties:
Claims
AlwaysSendClientClaims

PrefixClientClaims

Client -> Client (Source member list)
Thinktecture.IdentityServer.Core.Models.Client -> Thinktecture.IdentityServer.Core.EntityFramework.Entities.Client (Source member list)

Unmapped properties:
Claims
AlwaysSendClientClaims
PrefixClientClaims

There is no store type corresponding to the conceptual side type 'DateTimeOffset' of primitive type 'DateTimeOffset'

I am getting this error while adding EF code first migration on ClientConfigurationDbContext

I am using SQL server 2012 and EF 6. Not sure what is the issue, I have double check the connection string in App.Config which points to correct database.

here is what I have tried

  1. extended class from ClientConfigurationDbContext so that Code First migration detects it.
  2. run enable-migrations
  3. got the error.

Looks like it is from public virtual DateTimeOffset? Expiration { get; set; } in ClientSecret. It should not but note sure why?

Convert Entities.Scope to Models.Scope Error

When I login via Password flow, program validating scopes (on ValidateRequestedScopesAsync method, line 407, _scopes.GetScopesAsync() ) encounter a AutoMapper exception:

AutoMapper.AutoMapperMappingException was caught: "Missing type map configuration or unsupported mapping."

Feature Request: Admin interface

I have installed Identity Server 3 with Entity Framework. That's fine, it is working.

Now, I have to configure a new client to access it and I didn't find any repository that I could install in order to include a new client via web interface.

Do I have to include this new client direct into the database, in the tables "Clients" and "ClientRedirectUris"?

Schema differs from Scope Model

According to this Wiki page, The Type property distinguishes between identity and resource scopes. However, the physical schema for the "Scopes" table uses a bit column called "IsOpenIdScope".

AsyncHelper performs unnecessary thread context switches.

The AsyncHelper implementation creates unnecessary tasks, causing multiple thread context switches and should be replaced with just waiting on the original Task. This problem is even worse if the original Task has already run sequentially. For example the InMemoryScopeStore uses the Task.FromResult() method which creates a task that has already run sequentially.

Below the AsyncHelper class starts a new Task that just waits on the original task svc.GetScopesAsync().

var scopes = AsyncHelper.RunSync(async () => await svc.GetScopesAsync());

internal static class AsyncHelper
    {
        public static TResult RunSync<TResult>(Func<Task<TResult>> func)
        {
            return _myTaskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult();
        }
    }

This should be replaced with this:

var scopes = svc.GetScopesAsync().Result;

The AsyncHelper class should probably be removed.

Upgrade database from Beta3 to v3

hi

i working around with IdSrv3 [Beta] + IdSrv-EF [Beta] for a while and now in the new release v3 i see the database is changed. since i already have a db with data, how can i upgrade my exists database to compatible latest version?

Support for Users in EF

Thanks for all your hard work so far, but without persisting users this only gets you halfway there. This project really needs a User model and an implementation of IUserService that uses EF instead of in-memory users.

Or, if that is not the purpose of this library, please point me in the direction of how to do this :-)

EF Async

I noticed while reviewing this project that all the Stores (which have async signatures), do not actually utilize EF's async methods or the async/await pattern.

Was this done for a specific reason, is it on the roadmap, or is this something that can be PR'd in?

Thanks!

ClaimsPrincipalConverter potential problem when deserializing ClaimsPrincipal

In Thinktecture.IdentityServer.Core solution ClaimsIdentity is created using such statement

var id = new ClaimsIdentity(claims, authenticationType, Constants.ClaimTypes.Name, Constants.ClaimTypes.Role);

whereas in Thinktecture.IdentityServer.EntityFramework for ClaimsPrincipalConverter is used such statement

var id = new ClaimsIdentity(claims, source.AuthenticationType);

For that reason Name property of ClaimsPrincipal is null. I believe it should have value of claim with type name.

Upgrade database with migrate.exe tool

How can I upgrade/create database for configuration with migrate.exe tool. Now I get the next message:
ERROR: No migrations configuration type was found in the assembly 'Thinktecture.IdentityServer.Core.EntityFramework'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration.

IdServer APIs and "Lite" classes for serialization

Hi,

Just a thought - wouldn't it be better that the classes coming from IdentityServer were serializable/"Lite" classes instead of having each *Store-implementer to make their own *Lite-classes like here in EF?

Is there any reason these Lite-versions of classes could not be moved into IdServer Core?

We're using another storage mechanism than EF, and hence have to repro what is done here using the different serializer mechanisms.

CoreDbContext: Allow for specifying a default schema

I want to keep all my IdentityServer data tables and Membership data (e.g. ASP.NET Identity) in the same database under different schemas (e.g. schema = 'Auth' for IdentityServer and schema = 'User' for membership) in order to make things easier to manage.

To achieve this in the standard way, we would do this in the DBContext class (in this case CoreDbContext):

    /// <summary>
    /// Set schema name
    /// </summary>
    /// <param name="modelBuilder"></param>
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.HasDefaultSchema("Auth");

        .... <other code here>....
    }

So, to make the above work as it stands, we would want to do one of the following:

  1. Make the Database Context injectable in the project and inherit from CoreDbContext
  2. Add a config setting "Schema" and set it within CoreDbContext.

I can't think of any better ways to do this but I'm sure having access to CoreDbConect would be useful in other ways?

Deleting Entity from Navigation Property Collection Causes Update Exception

Given the nature of the way related collections are only exposed via navigation properties, I assumed it was necessary to perform change resolution for each navigation property on write-back of a record. However, I can't delete related entities because there are no identifying relationships established with foreign keys either in the model builder or with decorators. Any attempt to call .Remove() on the navigation property produces the following exception:

A relationship from the 'Client_ClientSecrets' AssociationSet is in the 'Deleted' state. Given multiplicity constraints, a corresponding 'Client_ClientSecrets_Target' must also in the 'Deleted' state.

The code looks similar to:

private void SyncClientSecrets(Thinktecture.IdentityServer.EntityFramework.Entities.Client entity, Client model)
{
    // Insert logic here

    var removedSecrets = entity.ClientSecrets.Where(cs => true).ToArray(); // Not actual remove test logic

    foreach (var secret in removedSecrets)
    {
        entity.ClientSecrets.Remove(secret);
    }
}

If this was not the intended method for updating related entities or I simply don't know of a better way EF offers to set the the related collection of entities, please let me know and feel free to disregard the report.

Model Names Too long

Hello,

I have updated from beta 3 to beta 4, using oracle RDBMS...
The entity ClientIdentityProviderRestriction exceeds oracle maximum name length of 30 characters.
Can it be shorter? like ClientIdProviderRestriction ?

Thanks

Token.Expiry not Sql 2005 compatible

Thought I would post a question to determine whether a decision was made to purposely support MSSQL 2008 and later. I am having to support a minimum of MSSQL 2005 where datetimeoffset is not a supported type. See https://msdn.microsoft.com/en-gb/library/bb630289.aspx

The entity Token has a property called Expiry of the .NET type DateTimeOffset.
See https://github.com/IdentityServer/IdentityServer3.EntityFramework/blob/master/Source/Core.EntityFramework/Entities/Token.cs#L42

Have you guys got experience with EF with how I can use this library against MSSQL 2005.

Database setup SQL script

Hi there,
Just wondering if there are any setup SQL scripts that could be used in a environment where I don't have permissions to create databases or tables.

I noticed membership reboot had a migration sql script, but could not find a similar one here.
Thanks

Hard coded to use Scope and Client Service

The BaseTokenService class is hard coded to use the EF scope and client services. This means that even though I have IdSvr3 configured to use an InMemoryService for Clients and scopes, it is not respecting this. I would think that this should probably be a dependency that is injected.

AddOrUpdate for Clients

We've set up IdSrv3 and EF model. However, when running seed method for client db context, I keep seeing duplicate entries after a few runs. First run, all clients inserted. Subsequent runs, it's like one of the clients randomly gets inserted over and over. Even Client.Id values get switched in the db table. What is wrong here?

Seed code is simple:

        var clients = new List<Client>
        {
           new Client { ClientId = "c1", ClientName = "C1",...
           new Client { ClientId = "c2", ClientName = "C2",...
           new Client { ClientId = "c3", ClientName = "C3",...
        };

         foreach (var client in clients)
        {
            context.Clients.AddOrUpdate(c => c.ClientId, client.ToEntity());

            // also tried:
            //context.Clients.AddOrUpdate(c => c.Id, client.ToEntity());
            //context.Clients.AddOrUpdate(c => new { c.Id, c.ClientId }, client.ToEntity());
        }

        SaveChanges(context);

Thanks

Support for other RDBMS than SQL Server

Hello All,

Sorry about "reopening" a closed issue #2....

As Brock has probably noticed ( by my constant nagging :) ), it is difficult to use current EF code first against other RDBMS than SQL Server, in my case Oracle.

I have been able to IDSRV + EF successfully against an Oracle RDBMS by the use of a interceptor.
The disadvantage of this approach, is that it requires to parse and modify every generated query before execution, and to disableDatabaseInitialization.
The advantage however is the possibility to do about anything, including type change, name, change, whatever, without changing code, by the use of app.config
<interceptors> <interceptor type="IDS.Core.ef6.ChangeSchemaNameCommandInterceptor, IDS.Core" /> </interceptors> <contexts> <context type="Thinktecture.IdentityServer.Core.EntityFramework.OperationalDbContext, Thinktecture.IdentityServer.Core.EntityFramework" disableDatabaseInitialization="true" /> <context type="Thinktecture.IdentityServer.Core.EntityFramework.ClientConfigurationDbContext, Thinktecture.IdentityServer.Core.EntityFramework" disableDatabaseInitialization="true" /> <context type="Thinktecture.IdentityServer.Core.EntityFramework.ScopeConfigurationDbContext, Thinktecture.IdentityServer.Core.EntityFramework" disableDatabaseInitialization="true" />

I have been looking for a better way to change the schema name from the dreaded "dbo." to the oracle user, uppercase table and column names (Oracle accepts camel case, but "hand made" queries implies the use of "" in every column, and table names, which is not the "normal" for oracle developers.

The better way, is by tweaking the OnModelCreating by injecting two conventions on the "OnModelCreating" on BaseDbContext. (pretty much this: http://msdn.microsoft.com/en-us/data/jj819164.aspx)

So, for it to work, and to allow it to adjust to other RDBMS, i would like to know if you would be willing to place some kind of plug-in or (dependency injection) on BaseDbContext;
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add<UppercaseForeignKeyNameConvention>(); modelBuilder.Conventions.Add<UppercaseTableSchemaConvention>();
base.OnModelCreating(modelBuilder);
}

The part in bold, would be whatever the user wants inside a class outside the EF assembly from a predefined interface.

Public Interface IBaseDbContextOnModelCreating
{
public void OnModelCreating(DbModelBuilder modelBuilder);
}

What is your thought on this?

ExpiredTokenCollector removed from sample

Hi Brock,

I've noticed that the ExpiredTokenCollector has been removed from the factory class in the sample app. Is that on purpose or by accident? If this is on purpose, what are the reasons behind this?

Thanks

Extending Idv3 Models

Brock,

This is more of a question than an issue however it may be worth looking into in general.

Has there be any thought to allowing an end user to inherit from and extend your core models (Client, Scope, etc...) and then inject the extended modules, probably through a factory, possibly a method on EntityFrameworkServiceFactory or even and overloaded constructor?

In my situation I am persisting my data to SQL Server, through EF and using Identity 2.0. Everything is working great but I am creating a lot of join tables (i.e. to link a specific client to a specific user) as part of a larger security model. These join tables are a simply as id, clientid, userid and while they get the job done, it would be nice to be able to extend them in a similar fashion to how IdentityUser can be extended. This would also allow for the creation of new navigation properties. Now of course this would require overridden stores and managers but I think it may be a valuable add.

Thank you for all of the great work that you and Dominick do.

Regards,

James Legan

Entities not being initialized

I am on the latest release, I cleared my database of the tables to make sure everything would update correctly, but not the entities are not being initialized in the database like they used to when you run the app. I'm looking through recent commits but not seeing anything that would have cause this right away, something change with the initialization process?

Data Serialization functionality should be injected into BaseTokenStore.

This will remove the dependency on Json.Net from the data repository code.

This would also address the bigger issue of the two hard coded services present in BaseTokenStore: ClientStore and ScopeStore. We are using an InMemoryClientStore and InMemoryScopeStore, and this won't work with the current BaseTokenStore implementation.

I recommend adding the following interface and class:

  public interface IDataSerializer
  {
    string ConvertToString<TValue>(TValue value);
    TValue ConvertFromString<TValue>(string json);
  }

  public class JsonDataSerializer : IDataSerializer
  {
    readonly IScopeStore _ScopeStore;
    readonly IClientStore _ClientStore;
    public JsonDataSerializer(IScopeStore scopeStore, IClientStore clientStore)
    {
      _ScopeStore = scopeStore;
      _ClientStore = clientStore;
    }
    JsonSerializerSettings GetJsonSerializerSettings()
    {
      var settings = new JsonSerializerSettings();
      settings.Converters.Add(new ClaimConverter());
      settings.Converters.Add(new ClaimsPrincipalConverter());
      settings.Converters.Add(new ClientConverter(_ClientStore));
      settings.Converters.Add(new ScopeConverter(_ScopeStore));
      return settings;
    }
    public string ConvertToString<TValue>(TValue value)
    {
      return JsonConvert.SerializeObject(value, GetJsonSerializerSettings());
    }
    public TValue ConvertFromString<TValue>(string json)
    {
      return JsonConvert.DeserializeObject<TValue>(json, GetJsonSerializerSettings());
    }
  }

Then inject the interface into BaseTokenStore:

        protected IDataSerializer DataSerializer
        {
          get { return _dataSerializer; }
        }
        protected BaseTokenStore(string connectionString, TokenType tokenType, IDataSerializer dataSerializer)
        {
            _connectionString = connectionString;
            TokenType = tokenType;
            _dataSerializer = dataSerializer;
        }
        public Task<T> GetAsync(string key)
        {
            using (var db = new CoreDbContext(ConnectionString))
            {
                var token = db.Tokens.FirstOrDefault(c => c.Key == key && c.TokenType == TokenType);
                if (token == null || token.Expiry < DateTime.UtcNow) return Task.FromResult<T>(null);

                T value = DataSerializer.ConvertFromString<T>(token.JsonCode);
                return Task.FromResult(value);
            }
        }

The ScopeConverter would also have to change:

        public ScopeConverter(IScopeStore scopeStore)
        {
          if (scopeStore == null) throw new ArgumentNullException("scopeStore");

          _scopeStore = scopeStore;
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
          var source = serializer.Deserialize<ScopeLite>(reader);
          var scopes = AsyncHelper.RunSync(async () => await _scopeStore.GetScopesAsync());
          return scopes.Single(x => x.Name == source.Name);
        }

Model Names Too long (part II)

Hello,

This has already occurred with issue #31.
The problem now has to be with the implementation of issue #43 with the property name UpdateAccessTokenClaimsOnRefresh, which is longer than 30 characters on Oracle, and will not work.

Concurrency issues

Hi guys!

Today I got the exception below. I'm trying to access my API in two async methods (to load items 0 to 20 as a 'batch' and then the control tries to see if there are more items to load (so 20 to 40)). When the token has been expired it tries to refresh it, but it seems that this happens at the same time and that some concurrency issues are in place.

I think we should do something like:
https://msdn.microsoft.com/en-us/library/vstudio/bb738618(v=vs.100).aspx

What do you guys think?

iisexpress.exe Information: 0 : [Thinktecture.IdentityServer.Core.ResponseHandling.TokenResponseGenerator]: 2/22/2015 7:36:04 PM -- Creating token response
iisexpress.exe Information: 0 : [Thinktecture.IdentityServer.Core.ResponseHandling.TokenResponseGenerator]: 2/22/2015 7:36:04 PM -- Creating token response
iisexpress.exe Information: 0 : [Thinktecture.IdentityServer.Core.ResponseHandling.TokenResponseGenerator]: 2/22/2015 7:36:04 PM -- Creating token response
iisexpress.exe Information: 0 : [Thinktecture.IdentityServer.Core.ResponseHandling.TokenResponseGenerator]: 2/22/2015 7:36:05 PM -- Processing refresh token request
iisexpress.exe Information: 0 : [Thinktecture.IdentityServer.Core.ResponseHandling.TokenResponseGenerator]: 2/22/2015 7:36:05 PM -- Processing refresh token request
iisexpress.exe Information: 0 : [Thinktecture.IdentityServer.Core.ResponseHandling.TokenResponseGenerator]: 2/22/2015 7:36:05 PM -- Processing refresh token request
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultTokenService]: 2/22/2015 7:36:05 PM -- Creating JWT access token
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultTokenService]: 2/22/2015 7:36:05 PM -- Creating JWT access token
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultTokenService]: 2/22/2015 7:36:05 PM -- Creating JWT access token
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Updating refresh token
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Token usage is one-time only. Generating new handle
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Refresh token expiration is sliding - extending lifetime
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Updating refresh token
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Updating refresh token
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Current lifetime: 111788
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Token usage is one-time only. Generating new handle
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Token usage is one-time only. Generating new handle
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- New lifetime: 1407788
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Refresh token expiration is sliding - extending lifetime
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Current lifetime: 111788
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- New lifetime: 1407788
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Refresh token expiration is sliding - extending lifetime
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- Current lifetime: 111788
Debug: [Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService]: 2/22/2015 7:36:05 PM -- New lifetime: 1407788
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.SqlServer.dll
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Core.OptimisticConcurrencyException' occurred in EntityFramework.SqlServer.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in EntityFramework.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' occurred in mscorlib.dll
iisexpress.exe Error: 0 : [Thinktecture.IdentityServer.Core.Configuration.Hosting.LogProviderExceptionLogger]: 2/22/2015 7:36:08 PM -- Unhandled exception
System.Data.Entity.Infrastructure.DbUpdateConcurrencyException: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions. ---> System.Data.Entity.Core.OptimisticConcurrencyException: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions.
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.ValidateRowsAffected(Int64 rowsAffected, UpdateCommand source)
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut)
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction)
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update()
   at System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
   at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.<SaveChangesInternal>b__27()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
   at System.Data.Entity.Internal.InternalContext.SaveChanges()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Internal.InternalContext.SaveChanges()
   at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
   at System.Data.Entity.DbContext.SaveChanges()
   at Thinktecture.IdentityServer.Core.EntityFramework.BaseDbContext.SaveChanges() in d:\Dev\Thinktecture.IdentityServer.v3.EntityFramework\Source\Core.EntityFramework\DbContexts\BaseDbContext.cs:line 33
   at Thinktecture.IdentityServer.Core.EntityFramework.BaseTokenStore`1.RemoveAsync(String key) in d:\Dev\Thinktecture.IdentityServer.v3.EntityFramework\Source\Core.EntityFramework\Stores\BaseTokenStore.cs:line 89
   at Thinktecture.IdentityServer.Core.Services.Default.KeyHashingTransientDataRepository`1.RemoveAsync(String key) in c:\etc\Dropbox\thinktecture\IdentityServer.v3\Core\source\Core\Services\Default\KeyHashingTransientDataRepository.cs:line 90
   at Thinktecture.IdentityServer.Core.Services.Default.DefaultRefreshTokenService.<UpdateRefreshTokenAsync>d__7.MoveNext() in c:\etc\Dropbox\thinktecture\IdentityServer.v3\Core\source\Core\Services\Default\DefaultRefreshTokenService.cs:line 134

TypeInitializationException

Hi,
our IdentityServer V3 instance was running fine, but this morning it suddenly started to rise System.TypeInitializationException for every request made to the .well-known/openid-configuration route.
Once restarted the site in IIS, the issue was gone.

Later i'll add some other details about the architecture we are using, untill then, do you have any clues about what happened ?

These are the information logged

System.TypeInitializationException
The type initializer for 'Thinktecture.IdentityServer.EntityFramework.Entities.EntitiesMap' threw an exception.
   at Thinktecture.IdentityServer.EntityFramework.Entities.EntitiesMap.ToModel(Scope s)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at WriteArrayOfScopeToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract )
   at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameter(XmlDictionaryWriter writer, PartInfo part, Object graph)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
   at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
   at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
   at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message, Boolean shouldRecycleBuffer)
   at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
   at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.SendReplyCore(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.HttpRequestContext.OnReply(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc)

MySQL issues with ClientConfigurationDbContext

I know that EntityFramework doesn't work perfectly with non-MSSQL DBMSs, but I used to live with this pain and even managed to work with auto migrations in MySQL/Postgres... I haven't started to debug this issue yet, have just wired up the EF sample... It is mid-night Friday, so I will post it here for the record and I will debug it later.

A general thought is that DateTimeOffset is a bad structure everywhere outside .NET boundary and even inside .NET. The best practice is to store DateTime in UTC, and when it matters - a time zone separately.

An exception of type 'System.Data.Entity.Core.MappingException' occurred in EntityFramework.dll but was not handled in user code

Additional information: Schema specified is not valid. Errors: 

(75,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.DateTimeOffset[Nullable=True,DefaultValue=,Precision=]' of member 'Expiration' in type 'IdentityServer3.EntityFramework.ClientSecret' is not compatible with 'MySql.timestamp[Nullable=True,DefaultValue=,Precision=0]' of member 'Expiration' in type 'CodeFirstDatabaseSchema.ClientSecret'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.