claims

How to get claim inside Asp.Net Core Razor View

让人想犯罪 __ 提交于 2019-12-18 04:34:32
问题 I did it in my rc1 project like: User.Claims.ElementAt(#).Value But after I switched to rtm it wouldn’t work anymore. When I debug the Razor view the object looks the same but User.Claims is just empty. Any idea what the reason could be. 回答1: Assuming you have claims attached to the current principal. In your Razor view: @((ClaimsIdentity) User.Identity) This will give you access to the ClaimsIdentity of the current user. In an effort to keep your claims fetching clean you may want to create

Access Claim values in controller in MVC 5

[亡魂溺海] 提交于 2019-12-17 17:39:37
问题 I have used OWIN authentication in my application. Login Action var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, result.UserFirstName)); claims.Add(new Claim(ClaimTypes.Sid, result.UserID.ToString())); var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); I want to access the UserName and UserID from different action. How can I access the values which is added in the claims? Update I have tried var claims = new List<Claim>(); claims.Add

When claims are available

对着背影说爱祢 提交于 2019-12-13 08:52:13
问题 I add a claim in GenerateUserIdentityAsync method: public class ApplicationUser : IdentityUser { public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); userIdentity.AddClaim(new Claim(ClaimsStaticStrings.Inactivity, company.Inactivity.ToString())); return userIdentity; } } Then I try to get it in Account/Login method: [HttpPost] [AllowAnonymous

Local STS to production

跟風遠走 提交于 2019-12-13 02:39:28
问题 I am now working on a web project where the authentication mechanism chosen is windows authentication(intranet application). Once the project goes live, after a gap of two months or so, an STS will be set up. Then the web project should start using it with out much change to the code. How to do it? I plan to use claims based authentication using WIF 4.5 with my own STS ( a WCF project/web application) and take it to live. once the STS is setup in intranet(ADFS)/cloud(WAAD). I simply change

Why am I getting a claim without a security token service?

孤街醉人 提交于 2019-12-12 10:14:54
问题 I am following this tutorial which shows how to build a claims aware ASP.NET WebForms app, with a page that "displays the claims in the token that was issued to you by the Security Token Service". Note that the tutorial "does not have detailed instructions for creating a Security Token Service (STS), and assumes you have already configured an STS." Now I followed the tutorial but I did not setup an STS myself. When I ran the web app I saw a claim on that page, specifically: Claim Type: http:/

Getting access to “employeeId” or “jobTitle” Claim via Asp.Net Core 2.2 with AzureAd

我是研究僧i 提交于 2019-12-11 23:55:12
问题 I'm trying to extend the claims I get back from AzureAd. I know there's more available, but I have no idea where to start. The documentation is all over the place. I basically have an ASP .Net Core 2.2 web application configured as follows: services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; })

Angularjs Adal and additional claims or properties for Authorization

烂漫一生 提交于 2019-12-11 14:58:52
问题 Scenario is Angularjs 1.6.5 app with a c# WebApi. Authentication is done against AAD with the use of angular-adal.js . Up to now, everything Works perfectly, as users are able to login through AAD and WebApi accepts the token. For this specific app, the roles are in an External application, to which the WebApi has Access. I have been able to add the role claims (after fetching them from the External app) with the use of WindowsAzureActiveDirectoryBearerAuthenticationOptions with the following

How do I request additional claims from Passive STS with WIF?

谁说胖子不能爱 提交于 2019-12-11 12:16:30
问题 I have the following: A website ASP.Net application acting as an Identity Provider (IDP STS) Federation Provider (FP STS) A Resource ASP.NET MVC WebSite acting as (RP) when trying to access a Resource in RP, it goes thru the FP STS and gets redirected to IDP STS. User puts their credentials and upon validity of that, IDP provides some claims that are passed to FP STS and then sent back to RP. on the RP side, claims are received and resource is proivded. How do i make additional claim requests

How to iterate over users in asp.net core SignalR?

与世无争的帅哥 提交于 2019-12-11 09:01:45
问题 In a SignalR application on .net core, I have a working piece of code similar to the following: public Task SendPrivateMessage(string user, string message) { var sender = Context.User.Claims.FirstOrDefault(cl => cl.Type == "username")?.Value; return Clients.User(user) .SendAsync("ReceiveMessage", $"Message from {sender}: {message}"); } This sends a message from the currently connected user, to the specified user. Now I'd like to send an individual message to every user connected; something

MVC 5 current claims autorization and updating claims

旧时模样 提交于 2019-12-10 21:44:19
问题 I have 2 questions regarding the claims: 1) In .Net 4.5 and MVC 5 how does the microsoft implements the autorization, when you set on controller AuthorizeAttirubte, does it check the database to get the user role? Or it uses the claims? I've read somewhere that microsoft uses database each time to verify the role, and they advised to write a new AuthorizeAttribute to implement claims authentication. This is the article i'm talking about: http://kevin-junghans.blogspot.be/2013/10/improving