• IdentityServer4 源码介绍


    IdentityServer4 源码介绍

    IdentityServer4 项目托管在 github上,Releases 下载地址:https://github.com/IdentityServer/IdentityServer4/releases

    7小时前,发布了 4.0 版本,就以这个版本为例,这里我选择下载 zip 包

    解压,根据 GitHub 上的说明先编译一下

     

    装好 sdk,git,在解压的项目根目录运行 build.ps1 或者 build.sh 即可。

    主要关注2个文件夹,一个是例子 samples,一个是源码 src

     src 目录下,有以下几个文件夹

    samples 下有以下几个文件夹

    结合 IdentityServer4 的官方文档来说说吧

    首先这是文档地址:https://identityserver4.readthedocs.io/en/latest/

     INTRODUCTION 这块主要是一些理论的东西,直接看完可能一头雾水,所以有个大概的了解之后,还是动手写下代码,就比较能理解它是什么了。

    跟着 QUICKSTARTS 动手写一写,很快就能理解 IdentityServer 是什么,要怎么用。了解各 grant type,知道怎么修改 config 文件,怎么配置 api,客户端怎么认证基本就ok了。

    这块都是一些简单的入门例子,代码在 samplesQuickstarts

    第一个例子:1_ClientCredentials 主要介绍使用 ClientCredentials 类型的认证方式。 

    // no interactive user, use the clientid/secret for authentication
    AllowedGrantTypes = GrantTypes.ClientCredentials,

    第二个例子:2_InteractiveAspNetCore 主要介绍使用 Code 类型的认证方式,这个应该是最复杂、最核心的方式。

     第三个例子 3_AspNetCoreAndApis ,也是 Code 类型,增加了使用 refresh token 这个东西。

    第四个例子 4_JavaScriptClient,也还是 Code 类型,主要是换成了 js 客户端 

    第五个例子 5_EntityFramework ,前面的几个例子 IdentityServer 的数据都是存在内存中,这里使用 ef core 存储到数据库中

     这里可以看到 configuration 数据和 Operational 数据使用 sqlserver 来存储,但是用户信息仍使用内存的 TestUser。

    第六个例子 6_AspNetIdentity

    不使用内存的用户信息,使用 aspnet core Identity 来管理用户,

    例子与源码结合,

    IdentityServer4 就是 IdentityServer4 的源码;

    AspNetIdentity 就是例子6中 asp net core identity 管理用户的源码

    例子5中使用 ef core 做持久化的源码就是剩下几个,先是 EntityFramework 然后又依赖 EntityFramework.Storage 最后依赖 Storage。

  • 相关阅读:
    AGC 015 E
    CF 1041 F. Ray in the tube
    AGC 005 D
    CF 348 D. Turtles
    2069: [POI2004]ZAW
    AGC 007 D
    zhengruioi 470 区间
    2653: middle
    Django 源码安装及使用
    Django MTV模型思想
  • 原文地址:https://www.cnblogs.com/ylka/p/13167908.html
Copyright © 2020-2023  润新知