1

I have installed asp.net core rc 2. I'm trying to create jwt token auth. In rc 1 all workrs very well. Even if you create a standard project, he did not start, because there are errors=( Correcting mistakes, i'm adding in startup.cs an code :

  public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddApplicationInsightsTelemetry(Configuration);
        var connection = "Data Source=DESKTOP-R3AP4AT\\SQLEXPRESS;Initial Catalog=Guide;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
        services.AddDbContext<GuideContext>(options => options.UseSqlServer(connection));
        services.AddAuthentication();
        services.AddMvc();
    }

Adding in project.json libs:

"AspNet.Security.OpenIdConnect.Server": "1.0.0-beta4",

and there was an error :error All project.json:

    {
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
    "Microsoft.AspNet.Authentication": "1.0.0-rc1-final",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-final",
    "Microsoft.AspNet.Security.OpenIdConnect" :  "1.0.0-beta3" 

  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
Kévin Chalet
  • 39,509
  • 7
  • 121
  • 131
alexqq
  • 129
  • 1
  • 10

1 Answers1

1

Don't mix different RC versions together. Your project.json mixes RC1 and RC2 modules.

All of them have to be RC2 or it won't work. There are dozen of breaking changes from old versions to new ones.

"Microsoft.AspNet.Authentication": "1.0.0-rc1-final",
"Microsoft.AspNet.Security.OpenIdConnect" :  "1.0.0-beta3",
"AspNet.Security.OpenIdConnect.Server": "1.0.0-beta4"

These lines are wrong, they are outdated packages.

"Microsoft.AspNetCore.Authentication": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Authentication.OpenIdConnect" :  "1.0.0-rc2-final",
"AspNet.Security.OpenIdConnect.Server": "1.0.0-beta5-final"

Should work.

Kévin Chalet
  • 39,509
  • 7
  • 121
  • 131
Tseng
  • 61,549
  • 15
  • 193
  • 205
  • 1
    FYI, the latest version of ASOS fully supports RC2: https://www.nuget.org/packages/AspNet.Security.OpenIdConnect.Server/1.0.0-beta5-final. – Kévin Chalet May 21 '16 at 15:28
  • @alexqq you're welcome ;) Since you're migrating to ASOS beta5, you might be interested by this other SO question: http://stackoverflow.com/q/37335676/542757. – Kévin Chalet May 21 '16 at 15:37
  • @Pinpoint, Thanks)), but I could not understand the example MVC.Server=(I hope the documentation will appear in the future, as to understand the new things in one example it is very difficult=( I need a simple authorization like old jwt auth, she works very well. Now in RC 2 i trying to implement OpenIdConnectServerProvider, but i have many errors like "Cannot resolve symbol ValidateClientAuthenticationContext" =(I wanted to write my diploma on asp.net core , but maybe i will write on asp.net mvc 5=(. Thanks for your help and sorry for my english, i'm from Ukraine) – alexqq May 21 '16 at 16:22
  • @alexqq many things have changed in ASOS beta5, and most of the events have been renamed/split/merged. Since I'm sure it will be a frequent question, feel free to open a new question and I'll post an answer mentioning how to migrate from the old events to the new ones ;) – Kévin Chalet May 21 '16 at 16:37
  • @Pinpoint you do not recommend to use jwt tokens and I shall listen to you))I would very much like to detailed instructions how to use opaque tokens and new OAuth2 validation middleware developed to support opaque tokens in future)And my question is whether the sending request has changed in the new version?What data should be sent to receive the token ? – alexqq May 21 '16 at 16:51
  • @alexqq open separate questions and send me the links, I'll answer them ASAP. Concerning the migration to opaque tokens, everything is indicated in this answer: http://stackoverflow.com/a/37335844/542757. – Kévin Chalet May 21 '16 at 16:54