zoukankan      html  css  js  c++  java
  • IdentityServer3 Custom Services

     

    IdentityServer3 provides many extensibility points for storage of data, validation logic and general functionality that are needed to support IdentityServer’s operation as a token service. These various extensibility points are collectively referred to as “services”.

    See here for the full list of the services.

    Mandatory services

    Three of the services are mandatory and must be configured by the implementer, they are:

    • the user service (IUserService)

    • the client store (IClientStore)

    • the scope store (IScopeStore)

    We provide a simple in-memory version of these three services as well as support for data stores via the related repos or community projects. See here for more details.

    Registering custom Services

    You can replace every service and register additional custom ones. This is encapsulated by the Registration class. A Registration represents a way for IdentityServer to obtain an instance of your service.

    Depending upon the design of your service you might want to have a new instance on every request, use a singleton, or you might require special instantiation logic each time an instance is needed. To accommodate these different possibilities, the Registration class provides many different constructors to register your service:

    • new Registration<T>(Type yourImplementation)
      • Registers yourImplementation as the class that implements the T interface.
    • new Registration<T, Impl>()
      • Registers Impl as the class that implements the T interface. This API is simply a convenience for the previous that accepts a Type parameter.
    • new Registration<T>(T singleton)
      • Registers the singleton instance passed as a singleton implementation of the T interface.
    • new Registration<T>(Func<IDependencyResolver, T> factory)
      • Registers a callback function that will be invoked to return an implementation of the T interface.
    var factory = new IdentityServerServiceFactory();
    factory.UserService = new Registration<IUserService, MyCustomUserService>();
    

    See the page on Dependency Injection (DI) page for more details.

    Service cleanup

    In all cases except for the singleton, if your service implements IDisposable, then Dispose will be called at the end of the HTTP request.

     示例:

    https://github.com/IdentityServer/IdentityServer3.Samples

    Dapper的实现:

    https://github.com/ranga543/IdentityServer3.Dapper

    来源:

    https://identityserver.github.io/Documentation/docsv2/advanced/customServices.html

  • 相关阅读:
    找出优先要作的工作
    我要作技术研发了
    确定配色方案
    今天公司搬家
    要作界面原型了
    使用自已的命名空间
    进行审核了
    那里有皮肤软件工开发包的源码???
    发葡萄
    作业务规则挺难
  • 原文地址:https://www.cnblogs.com/nirvanan/p/12986978.html
Copyright © 2011-2022 走看看