Questions tagged [asp.net-identity-3]

The third release of the ASP.NET Identity system which was designed to replace the previous ASP.NET Membership and Simple Membership systems. Use this tag if your question deals specifically to ASP.NET Identity 3 features. The [asp.net-identity] tag should be used if your question is not specific to ASP.NET Identity 3.

229 questions
13
votes
2 answers

Update Claims values in ASP.NET One Core

I have a Web Application in MVC 6 (Asp.Net One Core), and I'm using Claims based authentication. In the Login method I set the Claims: var claims = new Claim[] { new Claim("Name", content.Name), new Claim("Email", content.Email), new…
Martín
  • 2,985
  • 7
  • 24
  • 40
12
votes
6 answers

How to get current UserId in Identity 3.0? User.GetUserId returns null

I need to get ID of user that made some request. In previous versions of Identity I could do it like this: User.Identity.GetUserId(); But it seems it isn't available anymore. There is also something like: User.GetUserId(); But it always returns…
Piotrek
  • 9,838
  • 14
  • 66
  • 120
11
votes
2 answers

Identity 3.0 Getting a user by id when the id is "int"

I have had a look around for answers on this for Identity 3.0 and found little regarding getting a single user that has an int id. I have an asp.net-core mvc6 project in which I have converted all users and roles with string id's to have integer…
si2030
  • 2,799
  • 4
  • 25
  • 60
10
votes
2 answers

Create claims identity in Identity 3

Visual Studio 2015 scaffolding uses UserManager which cannot be used to create ClaimsIdentity. Does anyone have a working example on how to do this? The VS2015 scaffolding throws errors: public async Task
Ungaro
  • 504
  • 5
  • 13
9
votes
3 answers

Why this violates the constraint of type parameter 'TUser'?

I am trying to customize asp.net identity entities with the following ones: public class User : IdentityUser public class UserClaim : IdentityUserClaim public class UserLogin :…
Lorenzo
  • 28,103
  • 43
  • 117
  • 208
9
votes
1 answer

ASP.Net Core SignInManager lockoutOnFailure

ASP.Net Core has SignInManager which handles user authentication. One of the methods is PasswordSignInAsync(string username, string password, bool isPersistent, bool lockoutOnFailure). Setting lockoutOnFailure to true should temporarily lock out the…
Tedd Hansen
  • 11,020
  • 14
  • 57
  • 93
8
votes
1 answer

ASP.NET Identity (with IdentityServer4) get external resource oauth access token

I have been through the docs of identityServer4 and I have set it up to use Microsoft Office 365 as a login provider. When the user has logged in I want to make a button where he can allow my app to subscribe to his calendar events using the…
8
votes
2 answers

How to set the cookie validateInterval in ASP.NET Core?

I'm trying to set the validateInterval for an ASP.NET 5 RC1 application which makes use of ASP.NET Identity 3 I am trying to implement the code in this answer. there are many code sample like this answer but it seems it isn't valid in ASP.NET 5…
8
votes
4 answers

How to change login url when using asp.net 5

I am using asp.net 5 and Identity 3 to authenticate users but it always redirect to the default login url which is "Account/Login". I want to change it but there does not seem to be anywhere to set this options. I use AddIdentity() in Configure()…
Xiaowei.Jia
  • 345
  • 1
  • 3
  • 12
7
votes
2 answers

Asp.Net core MVC6 How to initially add roles in Identity 3

I've looked for this in Stackoverflow and so far it appears there are plenty of questions on adding roles in Identity 1 & 2 but its different in Identity 3. I want to seed roles in the database. I have just two. I intended to use _roleManager which…
si2030
  • 2,799
  • 4
  • 25
  • 60
6
votes
0 answers

IdentityServer4 - Session Management and idle timeout or period of inactivity

I have configured an IdentityServer with several clients, some of them are native applications using the Hybrid flow (Desktop, iOS, doesn't really matter). I want to force a logout on a user who's inactive for over X minutes, and if possible to…
6
votes
1 answer

How to change Web Api Core unauthorized behavior

The default ASP.NET Web Api Core behaviour for unauthorized request is to send 401/403 error with empty content. I'd like to change it by specifying some kind of Json response specifying the error. But I struggle to find a right place where I can…
SiberianGuy
  • 22,118
  • 44
  • 135
  • 253
6
votes
6 answers

Password reset token provider in ASP.NET core - IUserTokenProvider not found

Hello, I googled thoroughly but there is hundred examples from ASP.NET but nothing about ASP.NET Core. In order to getting password reset work I need to register an IUserTokenProvider instance into DI. Without it I get exception at following…
rudolfdobias
  • 1,335
  • 2
  • 10
  • 32
6
votes
2 answers

Creating a new AuthorizationHandler/IAuthorizationRequirement that uses a service

I am trying to create a new Authorization requirement, but it must use one of the services that I declare in ConfigureServices, and I have no idea how to pass that service to the new requirement in the same method as declaring the service. public…
Matthew
  • 256
  • 1
  • 3
  • 13
6
votes
1 answer

ASP.NET Core Identity - Extending Password Hasher

I'm working towards moving an application from Web Forms to MVC and opted to go with MVC 6 using ASP.NET Core. In my current application I have a custom password hasher used with Identity. The implementation is very simple in my custom UserManager…
Mat H.
  • 313
  • 3
  • 11
1
2
3
15 16