asp.net - Assign Role to Anonymous session -
our site uses asp role , membership provider system forms authentication. have organized our files folders enforce authorization list via folder web.config document (eg: must have admin role access pages in ~/admin folder) , not allow anonymous (not logged in) access except in site root. site hosted on iis7.5 .net 4.0 bindings , scriptmaps.
stakeholders asking allow pins authenticate specific usecases, user not yet have credentials, has recieved letter pin.
we wrote stack validate pins authentication, don't have way tell membership/role api logged in user, since bypassing our sso using pin.
i need find way assign role temporarily anonymous session when operator presents valid pin, can make use of pages in folders not otherwise allow anonymous access.
i've seen indications can tie profile info anonymous user i've been unable find info assigning user (session really) role.
does have ideas assigning role anonymous user can navigate past authorization lists requiring specific role?
try extending claimsauthenticationmanager. can override authenticate. should allow treat treat pin users authenticated, , allow assign roles.
public class claimstransformer : claimsauthenticationmanager { public override claimsprincipal authenticate(string resourcename, claimsprincipal incomingprincipal) {... you can activate extended claimsauthenticationmanager in global.asax.cs (or .vb). example asp.net mvc application. (you didn't mention whether using mvc or webforms.)
public class mvcapplication : system.web.httpapplication { ... protected void application_postauthenticaterequest() { var principal = claimsprincipal.current; var transformer = new claimstransformer(); var newprincipal = transformer.authenticate(string.empty, principal); thread.currentprincipal = newprincipal; httpcontext.current.user = newprincipal; } }
Comments
Post a Comment