小编Tom*_*nna的帖子

OWIN认证管道,以及如何正确使用Katana中间件?

我最近开始研究新的ASP.Net Identity框架和Katana中间件,那里有大量的代码和文档,但我看到的是很多相互矛盾的信息,我想这是一个代码更新频率增加的结果.

我期待使用WsFederation认证与内部ADFS分2次服,但方式OWIN认证管道工程有我有点困惑,我希望有人能提供一些确切的信息.

具体来说,我感兴趣的是应该连接中间件的顺序以及在各种场景中需要哪些模块,我想摆脱任何不需要的东西,同时确保过程尽可能安全.

例如,它似乎UseWsFederationAuthentication应该与之结合使用UseCookieAuthentication,但我不确定正确的AuthenticationType是什么(这篇帖子暗示它只是一个标识符字符串,但它的值是否显着?)或者即使我们仍然需要用SetDefaultSignInAsAuthenticationType.

我还注意到Katana项目讨论板上的这个帖子,Tratcher在那里提到了一个常见的错误,但是对于哪部分代码出错是不是很具体.

就个人而言,我现在使用以下(使用自定义SAML令牌处理程序将令牌字符串读入有效的XML文档),它对我有用,但它是否最佳?

var appURI = ConfigurationManager.AppSettings["app:URI"];
var fedPassiveTokenEndpoint = ConfigurationManager.AppSettings["wsFederation:PassiveTokenEndpoint"];
var fedIssuerURI = ConfigurationManager.AppSettings["wsFederation:IssuerURI"];
var fedCertificateThumbprint = ConfigurationManager.AppSettings["wsFederation:CertificateThumbprint"];

var audienceRestriction = new AudienceRestriction(AudienceUriMode.Always);

audienceRestriction.AllowedAudienceUris.Add(new Uri(appURI));

var issuerRegistry = new ConfigurationBasedIssuerNameRegistry();

issuerRegistry.AddTrustedIssuer(fedCertificateThumbprint, fedIssuerURI);

app.UseCookieAuthentication(
    new CookieAuthenticationOptions
    {
        AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType // "Federation"
    }
);

app.UseWsFederationAuthentication(
    new WsFederationAuthenticationOptions
    {
        Wtrealm = appURI,
        SignOutWreply = appURI,
        Configuration = new WsFederationConfiguration
        {
            TokenEndpoint = fedPassiveTokenEndpoint …
Run Code Online (Sandbox Code Playgroud)

c# adfs ws-federation owin katana

34
推荐指数
1
解决办法
2万
查看次数

TypeScript中的界面反差异

作为一个智力练习,我想我会看到我能够在TypeScript(0.9.5)中实现一些.Net泛型成员的程度,我已经得到了尽可能的List<T>但不确定我能不能进步.

(我意识到有这方面的解决方法,但我特别尝试使用与.Net库中存在的相同的实现,主要是尝试了解TypeScript中仍然存在的限制).

无论如何,忽略了我似乎无法以任何有意义的方式重载我的构造函数的事实,在.Net源代码中,构造函数List(IEnumerable<T> collection)检查传递的Enumerable是否为null,然后使用相反的方式将其强制转换为ICollection ICollection<T> c = collection as ICollection<T>.

在TypeScript中我这样做var c: ICollection<T> = collection(集合是一个IEnumerable<T>),但得到以下错误:

Cannot convert 'IEnumerable<T>' to 'ICollection<T>': Type 'IEnumerable<T>' is missing property 'Add' from type 'ICollection<T>'.

我目前的代码如下:

export module System {

    export module Collections {

        export interface IEnumerator {
            MoveNext(): boolean;
            Reset(): void;
            Current(): any;
        }
        export interface IEnumerable {
            GetEnumerator(): IEnumerator;
        }
        export interface ICollection extends IEnumerable {
            CopyTo(array: any[], index: number): void;
            Count(): number;
            SyncRoot(): …
Run Code Online (Sandbox Code Playgroud)

.net javascript c# typescript

4
推荐指数
1
解决办法
1467
查看次数

标签 统计

c# ×2

.net ×1

adfs ×1

javascript ×1

katana ×1

owin ×1

typescript ×1

ws-federation ×1