我有WCF服务,具有http和net.tcp端点.我已经将服务部署到IIS 7.5(Server 2008R2),一切都运行良好.
我的问题是,有没有办法通过Web.config为IIS应用程序设置启用的协议?现在我必须转到IIS中的应用程序并手动更改高级设置并将net.tcp添加到可用协议列表中,然后才能激活服务,请参阅图片了解屏幕截图.
我已经IsActive
在自定义用户服务中实现了该方法中的步骤之一:检查用户是否对请求的客户端具有任何角色。如果用户没有角色,IsActive
将返回false。这在常规情况下效果很好。但是,一旦实现了模拟工作流,就开始在login
页面和authorize
端点之间获得无限的重定向。
我可以IsActive
在模拟逻辑中实施相同的检查,但是还缺少其他内容吗?在我看来,我需要向IndentityServer添加一些内容,以便它显示错误/未经授权的页面,但是我不知道在哪里。
实施细节:
通过基于自定义acr_values 完全恢复AuthenticateResult
from PreAuthenticateAsync
来模拟角色。
var impersonate = context.SignInMessage.AcrValues.FirstOrDefault(x => x.StartsWith("impersonate"));
if (!string.IsNullOrWhiteSpace(impersonate))
{
var adminUserName = _owinContext.Authentication.User.FindFirst(Constants.ClaimTypes.Subject).Value;
var adminUser = _service.GetUser(adminUserName);
bool isAllowedImpersonation = true; //TODO:
var impersonateSplit = impersonate.Split(':');
if (impersonateSplit.Length != 2 || !isAloowedImpersonation)
{
context.AuthenticateResult = new AuthenticateResult("Invalid attempt to impersonate user");
}
var impesonateUserName = impersonateSplit[1];
var impersonateUser = _service.GetUser(impesonateUserName);
context.AuthenticateResult =
new AuthenticateResult(
impersonateUser.Username,
impersonateUser.Name,
claims: new[] { new Claim(Constants.ClaimTypes.ClientId, …
Run Code Online (Sandbox Code Playgroud) 我在使用ADFS2来保护从Passively Federated网站调用的后端WCF服务时遇到问题.我有被动联盟在网站上工作,但后端服务给我带来了问题.
拼图的碎片.
后端服务配置:
我使用行为扩展将WIF合并到管道中.
<ws2007FederationHttpBinding>
<binding name="WS2007FederationHttpBinding_IQuoteService">
<security mode="TransportWithMessageCredential">
<message establishSecurityContext="false">
<issuer address="https://myADFSserver/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256">
</issuer>
<issuerMetadata address="https://myADFSserver/adfs/services/trust/mex">
</issuerMetadata>
</message>
</security>
</binding>
</ws2007FederationHttpBinding>
<behaviors>
<serviceBehaviors>
<behavior name="">
<federatedServiceHostConfiguration name="Service.QuoteService" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<serviceCertificate findValue="000000000000000000000000000000" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service.QuoteService">
<endpoint address="" binding="ws2007FederationHttpBinding" contract="Service.IQuoteService" bindingConfiguration="WS2007FederationHttpBinding_IQuoteService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
客户端配置
使用"添加服务引用"工具添加服务时,将在客户端上创建以下配置:
<customBinding>
<binding name="https://myADFSserver/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256">
<security defaultAlgorithmSuite="Default" authenticationMode="IssuedTokenOverTransport"
requireDerivedKeys="false" securityHeaderLayout="Strict" …
Run Code Online (Sandbox Code Playgroud) 我希望单个Regex表达式匹配2组小写,大写,数字或特殊字符.长度也需要大于7.
我目前有这个表达方式
^(?=.*[^a-zA-Z])(?=.*[a-z])(?=.*[A-Z]).{8,}$
Run Code Online (Sandbox Code Playgroud)
但是,它强制字符串具有小写和大写以及数字或特殊字符.
我目前使用4个不同的正则表达式实现了这个,我用一些C#代码询问.
我计划在JavaScript中重用相同的表达式.
这是示例控制台应用程序,显示了两种方法之间的差异.
class Program
{
private static readonly Regex[] Regexs = new[] {
new Regex("[a-z]", RegexOptions.Compiled), //Lowercase Letter
new Regex("[A-Z]", RegexOptions.Compiled), // Uppercase Letter
new Regex(@"\d", RegexOptions.Compiled), // Numeric
new Regex(@"[^a-zA-Z\d\s:]", RegexOptions.Compiled) // Non AlphaNumeric
};
static void Main(string[] args)
{
Regex expression = new Regex(@"^(?=.*[^a-zA-Z])(?=.*[a-z])(?=.*[A-Z]).{8,}$", RegexOptions.ECMAScript & RegexOptions.Compiled);
string[] testCases = new[] { "P@ssword", "Password", "P2ssword", "xpo123", "xpo123!", "xpo123!123@@", "Myxpo123!123@@", "Something_Really_Complex123!#43@2*333" };
Console.WriteLine("{0}\t{1}\t", "Single", "C# Hack");
Console.WriteLine("");
foreach (var testCase in testCases)
{
Console.WriteLine("{0}\t{2}\t …
Run Code Online (Sandbox Code Playgroud) 我使用 IdentityServer4 并尝试添加多个相同类型的外部提供程序,在我的情况下是 OpenIdConnect。但是我遇到了一些问题。
services.AddAuthentication()
// Azure AD
.AddOpenIdConnect("oidc", "Azure AD", x =>
{
x.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
x.SignOutScheme = IdentityServerConstants.SignoutScheme;
x.ClientId = "some-client-id";
x.Authority = "https://login.microsoftonline.com/common";
x.ResponseType = OpenIdConnectResponseType.IdToken;
x.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false
};
})
// Identity Server
.AddOpenIdConnect("oidc", "My Other Identity Server", x =>
{
x.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
x.SignOutScheme = IdentityServerConstants.SignoutScheme;
x.ClientId = "some-other-client-id";
x.Authority = "http://localhost:6000"; //Another Identity Server I want to treat as external provider
x.RequireHttpsMetadata = false;
x.ResponseType = OpenIdConnectResponseType.IdToken;
x.TokenValidationParameters = …
Run Code Online (Sandbox Code Playgroud) asp.net-core-mvc openid-connect identityserver4 asp.net-core-2.0
asp.net-mvc ×2
c# ×2
wcf ×2
adfs ×1
adfs2.0 ×1
iis-7.5 ×1
javascript ×1
net.tcp ×1
regex ×1
web-config ×1
wif ×1