Last active
November 30, 2022 15:00
-
-
Save sitefinitySDK/af731e432dbb1554983396b2be51d031 to your computer and use it in GitHub Desktop.
SF_10.1, SF_10.2, SF_11.0, SF_11.1, SF_11.2, SF_12.0, SF_12.1, SF_12.2, SF_13.0, SF_13.1, SF_13.2, SF_13.3, SF_14.0, SF_14.1, SF_14.2, SF_14.3 - https://docs.sitefinity.com/request-access-token-for-calling-web-services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Owin; | |
using Microsoft.Owin.Security.Cookies; | |
using Microsoft.Owin.Security.OpenIdConnect; | |
using Owin; | |
using System.Collections.Generic; | |
using System.IdentityModel.Tokens; | |
using System.Threading.Tasks; | |
[assembly: OwinStartup(typeof(MVCImplicitFlow.Startup))] | |
namespace MVCImplicitFlow | |
{ | |
public class Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); | |
app.UseCookieAuthentication(new CookieAuthenticationOptions | |
{ | |
AuthenticationType = "Cookies" | |
}); | |
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions | |
{ | |
ClientId = "testApp", | |
Authority = "http://yousitefinitsite/Sitefinity/Authenticate/OpenID", | |
RedirectUri = "http://yoursite", | |
ResponseType = "id_token token", | |
Scope = "openid", | |
UseTokenLifetime = false, | |
SignInAsAuthenticationType = "Cookies", | |
Notifications = new OpenIdConnectAuthenticationNotifications | |
{ | |
SecurityTokenValidated = n => | |
{ | |
var id = n.AuthenticationTicket.Identity; | |
id.AddClaim(new System.Security.Claims.Claim("access_token", n.ProtocolMessage.AccessToken)); | |
n.AuthenticationTicket = new Microsoft.Owin.Security.AuthenticationTicket(id, n.AuthenticationTicket.Properties); | |
return Task.FromResult(0); | |
} | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment