Git Product home page Git Product logo

custom-policy-manager's Introduction

Manage custom polices in Azure AD B2C using Graph API

This is a sample management tool for B2C Custom Policies. Custom policy allows you to customize every aspect of the authentication flow.

Features

This sample demonstrates the following:

  • Create a custom policy

  • Update a custom policy

  • Delete a custom policy

  • List all custom policies

    Policy Manager

Getting Started

Prerequisites

This sample requires the following:

NOTE: This API only accepts user tokens, and not application tokens. See more information below about Delegated Permissions.

Quickstart

Create global administrator

  • A global administrator account is required to run admin-level operations and to consent to application permissions. (for example: [email protected])

Setup and usage

  1. Sign in to the Azure Portal using your Global Admin account.

  2. Select your Azure AD B2C directory from the directory filter.

  3. Select the Azure Active Directory Blade.

  4. Select Application Registrations, and then select New registration.

  5. Enter a Name for the application of your choice and then under Supported account types, select either Accounts in this organizational directory only(Single tenant) or Accounts in any organizational directory(Multitenant).

  6. Under Redirect URI, select Native, and then enter https://b2capi.com and then click on Register button.

  7. Once the app registration is successful, select it and under Manage click on API permissions.

  8. Click on Add a permission and select Microsoft Graph. Under delegated permission select Read and write your organization's trust framework policies and Application.Read.All.

  9. Click Save, and click Grant admin consent.

  10. Select the Azure AD B2C Blade in your Azure AD B2C directory.

  11. Select Application Registrations, and then select New registration.

  12. Enter a Name for the application of your choice and then under Supported account types, leave the default selection as it is. That is, Accounts in any identity provider or organizational directory (for authenticating users with user flows).

  13. Under Redirect URI, select Web, and then enter https://jwt.ms. Click on Register button.

  14. Open and build the solution in Visual Studio.

  15. Run the application:

    a. Set the Tenant to your B2C tenant: something.onmicrosoft.com

    b. Set the V1 Graph App Id to the Application Id from the App Registration created in the AAD Blade in Step 6.

    c. Set the B2C Application Id to the App Id of an Application Registration created in the AAD B2C Blade in Step 13.

    d. Set the reply url to a valid Reply URL set on the Application Registration referenced in Step 13 (https://jwt.ms).

  16. Click Login and login with the Global Admin of your B2C tenant. It must be in the format [email protected].

After logging in, any custom policies registered in the Identity Experience Framework at the portal or uploaded by this tool will be listed.

Select a Policy Folder that contains your XML files to upload them.

You can also open the working folder in VSCode by clicking Open Folder in VSCode.

Usage tips

  • Initial Usage

    • Select your working folder using the Select Policy Folder button.

    • Select Policy files to Upload into your Azure AD B2C tenant.

    • Click Update Policies to write the policy files into the tenant.

    • Use the Log area to troubleshoot any syntax errors.

    • Once the policies are uploaded, they will appear in the List of policies.

    • Select a Policy in the list of policies and click Launch with IE to test it.

  • Select Only show RPs to only show the Relying Party files in the Polices list. You must List Policies for this to update the list based on the selection.

  • Select a Policy and click Delete Policy to delete the policy from the tenant.

  • Select Delete all policies to delete all policies in this tenant.

  • Select Get Access token if you would like to also acquire an access token. This will only work if B2C Resource is not null. Enter the scopes into the B2C Resource text field.

  • To launch a policy, select the Relying Party file from the policy list, and then click Launch with IE or Launch with Chrome. Both options will open an private window.

  • To test a SAML Relying Party, click the SAML SP button. This will use a test site (https://b2csamlrp.azurewebsites.net/SP/) to build a SAML request for your B2C Policy to the authentication endpoint. The b2csamlrp will also parse the resulting SAML Assertion from B2C.

Questions and comments

Questions about this sample should be posted to Stack Overflow. Make sure that your questions or comments are tagged with [azure-ad-b2c].

Contributing

If you'd like to contribute to this sample, see CONTRIBUTING.MD.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Resources

The sample uses the Active Directory Authentication Library (ADAL) for authentication. The sample demonstrates delegated admin permissions. (App only permissions are not supported yet)

Delegated permissions are used by apps that have a signed-in user present (in this case tenant administrator). For these apps either the user or an administrator consents to the permissions that the app requests and the app is delegated permission to act as the signed-in user when making calls to Microsoft Graph. Some delegated permissions can be consented to by non-administrative users, but some higher-privileged permissions require administrator consent.

See Delegated permissions, Application permissions, and effective permissions for more information about these permission types.

custom-policy-manager's People

Contributors

jasjeetsuri avatar jassuri avatar pramodkumarhk89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

custom-policy-manager's Issues

Last merges contained some bad changes

Just some quick notes because I just pulled the last version and was unable to use it. Going back to an earlier one for now, may take a look at the issues later.

  • B2CPolicyManager.exe.msalcache.bin must not be checked in for the bin folder, it is a system local file and the app will crash on other systems on login
  • The new MSAL version fails to login with "no reply urls configured for this app", while the same AAD app still works with the previous ADAL version. Maybe the readme needs to be updated?

@PramodKumarHK89 fyi

System.NullReferenceException after logging in

Trying this out with a new B2C tenant. myPolicies.Value is null

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=B2CPolicyManager
StackTrace:
at B2CPolicyManager.B2CPolicyManager.UpdatePolicyList(PolicyList myPolicies) in C:\Projects\Microsoft\custom-policy-manager\B2CPolicyManager\Form1.cs:line 180

release/exe version is older than code version

There is a deprecancy between your code and the executable within GitHub.
Your documention is already up for your last code version.

May I suggest to upload the last executable version of your code within GitHub? This is useful for people that do not have Visual Studio.

Alternative implementation with DevOps integration?

Do you have a simple way I could simply commit my push to AzureDevOps (OR Github pipelines <-), and then let there be different flows for Dev, DevReview, UAT, Prod? (where a manual review would push the policy to the next config)?

I have different trust accounts for social providers so that only some Google/Facebook (App1 as DEVELOPMENT/ANON) and (App1 as SECURE/PII) authentication flow partitions (two different "app ids" created on the external IDP.

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.