Giter VIP home page Giter VIP logo

sharepointcontextsaml's Introduction

SharePointContextSaml

SAML Extensions for the SharePoint App Context helper

How to use

1. Create a SharePoin 2013 Provider Hosted App

Create a SharePoint 2013 Provider Hosted and High Trust app using Visual Studio 2013 and the ASP.NET MVC Template

2. Add SharePointContextSaml.cs to the web project

Download and add the SharePointContextSaml.cs file into your web project. Modify the namespace of the SharePointContextSaml.cs file to match the default namespace of your web project.

3. Modify TokenHelper.cs

In order for SharePointContextSaml.cs to be able to extend the default TokenHelper class TokenHelper.cs must be modified so the class declaration of TokenHelper has the partial keyword:

public static partial class TokenHelper {...}`

4. Modify SharePointContext.cs

The static constructor of the default SharePointContext class has to be modified to use the new SharePointContextSaml provider. Locate the static SharePointContextProvider constructor and modify it so it looks like this:

static SharePointContextProvider()
    {
    if (!TokenHelper.IsHighTrustApp())
    {
        SharePointContextProvider.current = new SharePointAcsContextProvider();
    }
    else
    {
        if(HttpContext.Current.User.Identity.AuthenticationType == "Federation") {
            SharePointContextProvider.current = new SharePointHighTrustSamlContextProvider();
        } else {
            SharePointContextProvider.current = new SharePointHighTrustContextProvider();
        }
    }
}

5. Modify web.config

The extension classes in SharePointContextSaml needs to know if federated (SAML) or Forms based authentication are used. The appSetting spsaml:ClaimProviderType can have the value of SAML or FBA. You also have to specify the name of the trusted provider added to SharePoint, the spsaml:TrustedProviderName app setting is used for that. Finally we need to specify which claims is used as an identifier, this is done using the spsaml:IdentityClaimType setting, which can have one of the following values SMTP (e-mail), SIP or UPN. The appSettings section should have settings like this after your modifications:

<add key="spsaml:ClaimProviderType" value="SAML"/>
<add key="spsaml:TrustedProviderName" value="High Trust SAML Demo"/>
<add key="spsaml:IdentityClaimType" value="SMTP"/>

6. Done

You don't have to modify any of your app code to now leverage SAML Claims in your High Trust SharePoint 2013 app.

More Information

For more information this blog post by Wictor Wilén.

sharepointcontextsaml's People

Contributors

wictorwilen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.