Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net OWIN身份验证提供程序是如何工作的?我怎么写一个定制的呢?_Asp.net_Authentication_Asp.net Membership_Owin - Fatal编程技术网

Asp.net OWIN身份验证提供程序是如何工作的?我怎么写一个定制的呢?

Asp.net OWIN身份验证提供程序是如何工作的?我怎么写一个定制的呢?,asp.net,authentication,asp.net-membership,owin,Asp.net,Authentication,Asp.net Membership,Owin,我正在查看Microsoft.OWIN.Security.Google的源代码,对于有多少类可以做这么简单的事情(重定向、获取cookie、检查),我感到有点困惑和不知所措 有人能解释一下各种部件是如何装配在一起的吗 中间件 扩展 等 。。。这样我就可以编写一个自定义提供程序了在调试器中进行了一些谷歌搜索并尝试了不同的想法之后,我最终得到了“复制粘贴编辑”: 这是一份简短的课程简历 扩展-没什么特别的,一个助手: // instead of using app.Use(typeof(Cust

我正在查看
Microsoft.OWIN.Security.Google
的源代码,对于有多少类可以做这么简单的事情(重定向、获取cookie、检查),我感到有点困惑和不知所措

有人能解释一下各种部件是如何装配在一起的吗

  • 中间件
  • 扩展

。。。这样我就可以编写一个自定义提供程序了

在调试器中进行了一些谷歌搜索并尝试了不同的想法之后,我最终得到了“复制粘贴编辑”:

这是一份简短的课程简历

扩展-没什么特别的,一个助手:

// instead of using
app.Use(typeof(CustomAuthenticationMiddleware), app, options);
// you can use
app.UseCustomAuthentication(options);
Middlware-方法用于将身份验证附加到owin管道

AuthenticationProvider-据我所知,这可以在外部重写,以便能够在不重写整个内容的情况下更改某些逻辑。有两种方法:

当处理程序在
AuthenticationHandler.AuthenticateCoreAsync()中完成所有身份验证时调用
Authenticated

ReturnEndpoint
,在外部身份验证之前的
AuthenticationHandler.InvokeAsync
中调用

但当我试图定制现有提供商(谷歌、facebook等)时,它似乎毫无用处

处理程序-以下是OAUTH2的所有功能

ApplyResponseChallengeAsync()
-生成授权端点URL并将useragent重定向到授权服务器

InvokeAsync()
-处理get to RedirectEndpoint(/signin google或授权服务器上设置的任何内容),并将用户返回到启动控制器(或回调)。它正在进行重定向,并设置了所有需要的cookie

AuthenticateCoreAsync()-执行对授权服务器的所有服务器端调用。创建创建之前创建适当cookie所需的所有身份声明