Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5936467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:24:09+00:00 2026-05-22T15:24:09+00:00

I have an MVC app that I would like to add claims-based authorization to.

  • 0

I have an MVC app that I would like to add claims-based authorization to. In the near future we will use ADFS2 for federated identity but for now we will used forms auth locally.

Has anyone seen a tutorial or blog post about the best way to use WIF without an external identity provider?

I have seen the following but it is a year old now and I think there should be an easier solution:

http://geekswithblogs.net/shahed/archive/2010/02/05/137795.aspx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:24:10+00:00Added an answer on May 22, 2026 at 3:24 pm

    You can use WIF in MVC without an STS.

    I used the default MVC2 template, but it should work with MVC 3 too.

    You need to:

    1- Plug WIF ‘s SessionAuthenticationModule (web.config)

    < add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    

    2- Wherever you authenticate your users, create a ClaimsPrincipal, add all required claims and then create a SessionSecurityToken. This is the LogOn Action in the AccountController created by MVC:

     [HttpPost]
            public ActionResult LogOn(LogOnModel model, string returnUrl)
            {
                if (ModelState.IsValid)
                {
                    if (MembershipService.ValidateUser(model.UserName, model.Password))
                    {
                        var cp = new ClaimsPrincipal();
                        cp.Identities.Add(new ClaimsIdentity());
                        IClaimsIdentity ci = (cp.Identity as IClaimsIdentity);
    
                        ci.Claims.Add(new Claim(ClaimTypes.Name, model.UserName));
    
                        SessionSecurityToken sst = FederatedAuthentication
                            .SessionAuthenticationModule
                            .CreateSessionSecurityToken(cp,
                                                        "MVC Test",
                                                        DateTime.
                                                            UtcNow,
                                                        DateTime.
                                                            UtcNow.
                                                            AddHours
                                                            (1),
                                                        true);
    
    
                        FederatedAuthentication.SessionAuthenticationModule.CookieHandler.RequireSsl = false;
                        FederatedAuthentication.SessionAuthenticationModule.AuthenticateSessionSecurityToken(sst, true);
    
    
                        //FormsService.SignIn(model.UserName, model.RememberMe);
                        if (!String.IsNullOrEmpty(returnUrl))
                        {
                            return Redirect(returnUrl);
                        }
                        else
                        {
                            return RedirectToAction("Index", "Home");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "The user name or password provided is incorrect.");
                    }
                }
    
                // If we got this far, something failed, redisplay form
                return View(model);
            }
    

    I just added the required lines and left everything else the same. So some refactoring might be required.

    From there on, your app will now receive a ClaimsPrincipal. All automatically handled by WIF.

    The CookieHandler.RequiresSsl = false is only because it’s a dev machine and I’m not deploying on IIS. It can be defined in configuration too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm practicing writing MVC applications. I have a Mastermind game, that I would like
I have a php application that doesn't use the mvc model that i would
I have a directory structure in my Php mvc app that is currently like
I have an MVC app that does a lot of work with jQuery ajax
I have C# MVC web app that has some textboxes that in IE9 you
So, I have an asp.net mvc app that is being worked on by multiple
I have a MVC app and using JQuery. I have anchor that I setup
I have a spring web app that uses Hibernate and Velocity. It's an MVC
I have an ASP.NET MVC app and I want to add to each page
I have an MVC app that is basically one page with a bunch of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.