Freigeben über


Running Windows Identity Foundation (WIF) Extensions For OAuth 2.0 Sample

In this post I have captured steps required to run Windows Identity Foundation (WIF) Extensions for OAuth 2.0 Sample. Same steps are provided also in the accompanying document that comes with the download.

Create AppFabric Namespace

  1. Got to https://portal.appfabriclabs.com
  2. Create new Namespace, for example, MyOAuthNS.

Create New Service Identity

  1. In the AppFabric portal click on your newly created Namespace and then click on Access Control Service ribbon
  2. New IE window/tab opens with ACS v2 portal for your new Namespace, similar to this https://myoauthns.accesscontrol.appfabriclabs.com/v2/mgmt/web
  3. Click on Service Identities link on the left.
  4. On the Service Identities page click on Add link.
  5. Provide name for the new identity in the Name textbox, for example, FabrikamClient.
  6. Optionally provide description for the identity in Description textbox.

Add credentials to your newly created service identity

  1. On the Edit Service Identity page (the page you should have been presented right after creating the identity) click on Add link in Credentials section of the page.
  2. On the Add Credential page specify the following information:
    1. Type – choose Password for credential type form the dropdown list.
    2. Password – specify your password, for example, FabrikamSecret.
    3. Effective date – leave default value, should be today’s date.
    4. Expiration date – leave default value, should be today’s date + on year.
    5. Click on Save button.
  3. Click Save button on Edit Service Identity page.

Add new relying party application.

  1. Click on Relying Party Applications link on the left.
  2. On the Relying Party Applications page click on Add link.
  3. On the Add Relying Party Application page specify the following information:
    1. Name: - Customer Information Service.
    2. Realm: - https://contoso/CustomerInformationService/
    3. Return URL: - https://localhost/
    4. Token format: – SWT
    5. Token lifetime (secs): – 5.
    6. Identity providers: – uncheck all.
    7. Rule groups: – make sure only Create new Rule Group option is checked and all others are unchecked.
    8. Token signing key – click Generate button to generate the key.
    9. Effective date – leave default, should be today’s date.
    10. Expiration date – leave default, should be today’s date + one year.

Specify Configuration Information in the Code

  1. On Access Control Service portal obtain ManagementClient’s password. To do so follow these steps:

    1. Click on the Management Service link on the left.
    2. On the Management Service  page click on the ManagementClient link.
    3. On the Edit Management Service Account page click on Password link.
    4. Copy the value in the Password textbox.
  2. Open Oauth with ACS sample.sln solution file in Visual Studio 2010.

  3. Open SamplesConfiguration.cs file in Common project.

  4. Update the configuration with your information. It should look similar to the following:

     //
    // ACS service Namespace
    //
    public const string ServiceNamespace = "myoauthns";
    
    //
    // Management Service Configuration information.
    //
    public const string ManagementServiceIdentityName = "ManagementClient";
    public const string ManagementServiceIdentityKey = "lXoVR+...zfwyemjrZg=";
    
    //
    // Relying Party Configuration.
    //
    public const string RelyingPartyApplicationName = "Customer Information Service";
    public const string RelyingPartyRealm = "https://contoso/CustomerInformationService/";
    public const string RelyingPartySigningKey = "VkHDFBcgu6...fNKw51Jeoes=";
    
    //
    // Client Configuration Information.
    //
    public const string ClientIdentity = "FabrikamClient";
    public const string ClientSecret = "FabrikamSecret";
    

Run the application

  1. Open command prompt as Administrator with elevated privileges. Click on windows start button and type cmd. Right click on cmd.exe when it appears in search results and click on Run as administrator option.
  2. Change directory to the root folder of the sample in the command prompt.
  3. Run SetupSample.bat to create virtual directories, configure certificates and perform other configurations.
  4. Update Management Service reference. This is due to recent breaking changes of ACS v2.
  5. Run ConfigureAcsConsoleApplication by right clicking on the project in Solution Explorer choosing Debug options and then Start New Instance option. This needs to be done once.
  6. Navigate to https://localhost/WebClient/default.aspx.
  7. Follow the instructions on the web UI.