Skip to content

OWIN middleware provider for to login using Obsidian Portal. Works with Asp.Net MVC5

License

Notifications You must be signed in to change notification settings

willegetz/NoTPK.Owin.Security.ObsidianPortal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NoTPK.Owin.Security.ObsidianPortal

NoTPK.Owin.Security.ObsidianPortal is an OWIN authentication provider for Obsidian Portal

Installation via NuGet Package

Create an Obsidian Portal app to get your unique Client ID and Client Secret from: https://www.obsidianportal.com/oauth/clients/new

Install-Package NoTPK.Owin.Security.ObsidianPortal

Add the following to Startup.Auth.cs (VS2013) or AuthConfig.cs (VS2012):

        app.UseObsidianPortalAuthentication(
            appId: "",
            appSecret: "");


Add the following to the AccountController.cs

In the ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) before the "await SignInAsync(user, isPersistent: false);"

    await StoreAuthTokenClaims(user);


Add the following method to the AccountController.cs

	private async Task StoreAuthTokenClaims(ApplicationUser user)
	{
		ClaimsIdentity claimsIdentity =
			await AuthenticationManager.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie);
		if (claimsIdentity != null)
		{
			var currentClaims = await UserManager.GetClaimsAsync(user.Id);
			var tokenClaims = claimsIdentity.Claims.Where(c => c.Type.StartsWith("urn:tokens"));
			foreach (var tokenClaim in tokenClaims)
			{
				if (!currentClaims.Contains(tokenClaim))
				{
					await UserManager.AddClaimAsync(user.Id, tokenClaim);
				}
			}
		}
	}

Attribution

This product includes software developed at: Microsoft Open Technologies, Inc.

License

Apache v2 License

About

OWIN middleware provider for to login using Obsidian Portal. Works with Asp.Net MVC5

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published