{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer4/issues/65","repository_url":"https://api.github.com/repos/IdentityServer/IdentityServer4","labels_url":"https://api.github.com/repos/IdentityServer/IdentityServer4/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/IdentityServer/IdentityServer4/issues/65/comments","events_url":"https://api.github.com/repos/IdentityServer/IdentityServer4/issues/65/events","html_url":"https://github.com/IdentityServer/IdentityServer4/issues/65","id":145931572,"number":65,"title":"anyone can shows how to implement IDS4 to use AspIdentity?","user":{"login":"hmheng","id":11830387,"avatar_url":"https://avatars.githubusercontent.com/u/11830387?v=3","gravatar_id":"","url":"https://api.github.com/users/hmheng","html_url":"https://github.com/hmheng","followers_url":"https://api.github.com/users/hmheng/followers","following_url":"https://api.github.com/users/hmheng/following{/other_user}","gists_url":"https://api.github.com/users/hmheng/gists{/gist_id}","starred_url":"https://api.github.com/users/hmheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmheng/subscriptions","organizations_url":"https://api.github.com/users/hmheng/orgs","repos_url":"https://api.github.com/users/hmheng/repos","events_url":"https://api.github.com/users/hmheng/events{/privacy}","received_events_url":"https://api.github.com/users/hmheng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-05T09:18:58Z","updated_at":"2016-04-07T18:00:06Z","closed_at":null,"body":"I can't find anyway to use AspIdentity classes and I couldn't find a way to implement custom classes too. Can anyone help me?\r\nThanks."},"comment":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer4/issues/comments/207029476","html_url":"https://github.com/IdentityServer/IdentityServer4/issues/65#issuecomment-207029476","issue_url":"https://api.github.com/repos/IdentityServer/IdentityServer4/issues/65","id":207029476,"user":{"login":"TheRubble","id":482262,"avatar_url":"https://avatars.githubusercontent.com/u/482262?v=3","gravatar_id":"","url":"https://api.github.com/users/TheRubble","html_url":"https://github.com/TheRubble","followers_url":"https://api.github.com/users/TheRubble/followers","following_url":"https://api.github.com/users/TheRubble/following{/other_user}","gists_url":"https://api.github.com/users/TheRubble/gists{/gist_id}","starred_url":"https://api.github.com/users/TheRubble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheRubble/subscriptions","organizations_url":"https://api.github.com/users/TheRubble/orgs","repos_url":"https://api.github.com/users/TheRubble/repos","events_url":"https://api.github.com/users/TheRubble/events{/privacy}","received_events_url":"https://api.github.com/users/TheRubble/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T18:00:05Z","updated_at":"2016-04-07T18:00:05Z","body":"```\r\npublic class AspNetIdentityProfileService : IProfileService\r\n    {\r\n        private readonly UserManager<IdentityUser> _userManager;\r\n\r\n        public AspNetIdentityProfileService(UserManager<IdentityUser> userManager)\r\n        {\r\n            _userManager = userManager;\r\n        }\r\n\r\n        async public Task GetProfileDataAsync(ProfileDataRequestContext context)\r\n        {\r\n            var subject = context.Subject;\r\n            if (subject == null) throw new ArgumentNullException(nameof(context.Subject));\r\n\r\n            var subjectId = subject.GetSubjectId();\r\n\r\n            var user = await _userManager.FindByIdAsync(subjectId);\r\n            if (user == null)\r\n                throw new ArgumentException(\"Invalid subject identifier\");\r\n\r\n            var claims = await GetClaimsFromUser(user);\r\n            if (!context.AllClaimsRequested)\r\n            {\r\n                var requestedClaimTypes = context.RequestedClaimTypes;\r\n                if (requestedClaimTypes != null)\r\n                    claims = claims.Where(c => requestedClaimTypes.Contains(c.Type));\r\n                else\r\n                    claims = claims.Take(0);\r\n            }\r\n            context.IssuedClaims = claims;\r\n        }\r\n\r\n        async public Task IsActiveAsync(IsActiveContext context)\r\n        {\r\n            var subject = context.Subject;\r\n            if (subject == null) throw new ArgumentNullException(nameof(context.Subject));\r\n\r\n            var subjectId = subject.GetSubjectId();\r\n            var user = await _userManager.FindByIdAsync(subjectId);\r\n\r\n            context.IsActive = false;\r\n\r\n            if (user != null)\r\n            {\r\n                if (_userManager.SupportsUserSecurityStamp)\r\n                {\r\n                    var security_stamp = subject.Claims.Where(c => c.Type == \"security_stamp\").Select(c => c.Value).SingleOrDefault();\r\n                    if (security_stamp != null)\r\n                    {\r\n                        var db_security_stamp = await _userManager.GetSecurityStampAsync(user);\r\n                        if (db_security_stamp != security_stamp)\r\n                            return;\r\n                    }\r\n                }\r\n\r\n                context.IsActive =\r\n                    !user.LockoutEnabled ||\r\n                    !user.LockoutEnd.HasValue ||\r\n                    user.LockoutEnd <= DateTime.Now;\r\n            }\r\n        }\r\n\r\n        async private Task<IEnumerable<Claim>> GetClaimsFromUser(IdentityUser user)\r\n        {\r\n            var claims = new List<Claim>\r\n            {\r\n                new Claim(JwtClaimTypes.Subject, user.Id),\r\n                new Claim(JwtClaimTypes.PreferredUserName, user.UserName)\r\n            };\r\n\r\n            if (_userManager.SupportsUserEmail)\r\n            {\r\n                claims.AddRange(new[]\r\n                {\r\n                    new Claim(JwtClaimTypes.Email, user.Email),\r\n                    new Claim(JwtClaimTypes.EmailVerified, user.EmailConfirmed ? \"true\" : \"false\", ClaimValueTypes.Boolean)\r\n                });\r\n            }\r\n\r\n            if (_userManager.SupportsUserPhoneNumber && !string.IsNullOrWhiteSpace(user.PhoneNumber))\r\n            {\r\n                claims.AddRange(new[]\r\n                {\r\n                    new Claim(JwtClaimTypes.PhoneNumber, user.PhoneNumber),\r\n                    new Claim(JwtClaimTypes.PhoneNumberVerified, user.PhoneNumberConfirmed ? \"true\" : \"false\", ClaimValueTypes.Boolean)\r\n                });\r\n            }\r\n\r\n            if (_userManager.SupportsUserClaim)\r\n            {\r\n                claims.AddRange(await _userManager.GetClaimsAsync(user));\r\n            }\r\n\r\n            if (_userManager.SupportsUserRole)\r\n            {\r\n                var roles = await _userManager.GetRolesAsync(user);\r\n                claims.AddRange(roles.Select(role => new Claim(JwtClaimTypes.Role, role)));\r\n            }\r\n\r\n            return claims;\r\n        }\r\n    }\r\n```\r\n\r\nDisclaimer I found this code somewhere else, it's not my own."}}