Tag: ws federation

如何避免’SamlAssertion.NotOnOrAfter条件不满意’错误

最近,我开始在现有的Web应用程序上使用基于声明的身份validation。 因为应用程序使用jQuery,尤其是AJAX函数,我不得不改变处理程序,不要尝试重定向XmlHTTPRequests ,而是返回403状态,这更容易处理。 这是FederatedAuthentication.WSFederationAuthenticationModule.AuthorizationFailed事件hanlder: protected void WSFederationAuthenticationModule_AuthorizationFailed(object sender, AuthorizationFailedEventArgs e) { //WSFederationAuthenticationModule sam = (WSFederationAuthenticationModule)sender; HttpContext context = HttpContext.Current; HttpRequest req = context.Request; HttpResponse resp = context.Response; if (req == null || resp == null) return; if ((resp.StatusCode == 302 || resp.StatusCode == 401) && req.Headers[“X-Requested-With”] == “XMLHttpRequest”) { resp.StatusCode = 403; e.RedirectToIdentityProvider = false; […]

在OwinStartup之后为新租户添加Owin管道中间件

我有一个多租户应用程序,每个租户可以为WsFed或OpenIdConnect定义自己的ClientID,Authority等。 所有租户都在OwinStartup注册如下: public void Configuration(IAppBuilder app) { List WsFedTenantOptions = BuildWsFedTenantOptionsList(); List OpenIdConnectTenantOptions = BuildOpenIdConnectTenantOptionsList(); app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions() { CookieSecure = CookieSecureOption.Never }); foreach (var WsFedTenantOption in WsFedTenantOptions) app.UseWsFederationAuthentication(WsFedTenantOption); foreach (var OpenIdConnectTenantOption in OpenIdConnectTenantOptions) app.UseOpenIdConnectAuthentication(OpenIdConnectTenantOption); … } 它通过context.Authentication.Challenge(AuthenticationType)切换要使用的STS。 这工作得很好。 问题是当新租户注册时,如何在没有应用程序池回收的情况下访问IAppBuilder并添加新的AuthenticationOptions ?

使用AD FS和OWIN的SSO如何创建帐户和处理权限

我配置了一个使用AD FS的Web App,为此我使用了OWIN。 对于登录,一切都好。 如果我是域名的用户并访问该网站,则会自动连接。 但我想要的是在登录后自己处理用户和角色。 所以我想用这个AD帐户检查我的数据库中是否存在用户(此过程将在另一个应用程序登录之前生成) 我想使用Microsoft的Identity来处理声明(角色和权限)。 但我不明白如何将我的代码用于处理来自AD FS(使用Ws-Federation)的成功连接,并添加validation并填写正确的角色。 我在ConfigureAuth中的代码: public partial class Startup { private static string realm = ConfigurationManager.AppSettings[“ida:Wtrealm”]; private static string adfsMetadata = ConfigurationManager.AppSettings[“ida:ADFSMetadata”]; private NLogLoggingService _loggingService; public void ConfigureAuth(IAppBuilder app) { _loggingService = new NLogLoggingService(“Startup”); _loggingService.Debug(“ConfigureAuth”); app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseWsFederationAuthentication( new WsFederationAuthenticationOptions { Wtrealm = realm, MetadataAddress = adfsMetadata, //CallbackPath […]

Sharepoint 2013中的联合身份validation:获取rtFa和FedAuth cookie

场景如下:我需要对用户(使用他的大学帐户)执行联盟身份validation到他大学的Sharepoint站点,并获得FedAuth和rtFa cookie (我必须将其传递给SharePoint REST webservices)为了访问资源)。 我做了一些尝试,但每个问题至少有一个问题: 1)使用Microsoft.SharePoint.Client库 ClientContext context = new ClientContext(host); SharePointOnlineCredentials creds = new SharePointOnlineCredentials(user, passw); context.Credentials = creds; Uri sharepointuri = new Uri(host); string authCookie = creds.GetAuthenticationCookie(sharepointuri); Web web = context.Web; context.Load(web, w=>w.Lists); context.ExecuteQuery(); fedAuthString = authCookie.Replace(“SPOIDCRL=”, string.Empty); 这样我设法获得FedAuth cookie,但我无法获得rtFa cookie 。 我怎么能在这一点上获得rtFa cookie? 我是否可以拦截此类操作中涉及的HTTP请求(即context.ExecuteQuery()) – 其中可能包含标题中的rtFa cookie? 或者,我是否可以通过仅利用FedAuth cookie获得rtFa cookie? 2)使用MsOnlineClaimsHelper […]

ADFS身份validation期间的间歇重定向循环

我正在使用Owin配置我的ASP.NET MVC 5(.NET 4.5,IIS 7/8)应用程序以对第三方ADFS设置进行身份validation: app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType }); app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions { Wtrealm = Settings.Auth.Wtrealm, MetadataAddress = Settings.Auth.MetadataAddress }); 我还有一个自定义身份validationfilter(与AuthorizeAttribute结合使用): public class OwinAuthenticationAttribute : ActionFilterAttribute, IAuthenticationFilter { public void OnAuthentication(AuthenticationContext filterContext) { var user = filterContext.RequestContext.HttpContext.User; var authenticated = user.Identity.IsAuthenticated; if (!authenticated) { return; } /* Redirect to profile setup if […]