Using Token Based Authentication, clients are not dependent on a specific authentication mechanism. A token is generated by the server if the user is authenticated and send it back to the user. So to acces a specific ressource, the client must include the generated token in the header of subsequent requests and the Web API Server have some APIs …
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.vs
TokenAuthWebApiCore.Server.IntegrationTest
TokenAuthWebApiCore.Server
.gitignore
README.md
TokenAuthWebApiCore.sln

README.md

Asp.Net-Web-Api-Core-2.0-Integration-testing-using-EntityFrameworkCore-LocalDb-and-Xunit2

To migrate JW from asp.net core 1.x to asp.net core 2.0 proceed as follows

1. Go to project properties and choose .NET Core 2.0 as TargetFramework

2. open ConfigureServices of startup.cs file and paste this line of code :

        services.AddIdentity<MyUser, MyRole>().AddEntityFrameworkStores<SecurityContext>();
        services.AddAuthentication((cfg =>
        {
            cfg.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
            cfg.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
        })).AddJwtBearer(options =>
        {
            options.RequireHttpsMetadata = false;

            options.TokenValidationParameters = new TokenValidationParameters
            {
                ValidIssuer = Configuration["JwtSecurityToken:Issuer"],
                ValidAudience = Configuration["JwtSecurityToken:Audience"],
                ValidateIssuerSigningKey = true,
                IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["JwtSecurityToken:Key"])),
                ValidateLifetime = true
            };
        });

3. open Configure of Startup.cs class and remove this lines of code :

app.UseJwtBearerAuthentication(.................)
and app.UseIdentity()

4 . paste this line of code

   app.UseAuthentication();