Tổng quan về IdentityServer - easywebhub/NetCoreIdentityServer GitHub Wiki

##Tham khảo:

http://docs.identityserver.io/en/release/

##Phân biệt IdentityServer3 vs IdentityServer4

Identity Server is designed to run as a self-hosted component, which was difficult to achieve with ASP.NET 4.x with MVC still being tightly coupled to IIS, and System.Web, resulting in an internal view engine served up by the katana component. With Identity Server 4 running on ASP.NET Core, we can now use any UI technology and host IdentityServer in any environment ASP.NET Core can run in. This also means we can now integrate with existing login forms/systems, allowing for in place upgrades.

(Tham khảo https://www.scottbrady91.com/Identity-Server/Getting-Started-with-IdentityServer-4)

Về cơ bản thì IdentityServer3 và 4 không có khác biệt nhiều về concepts. Tuy nhiên IdentityServer3 thì được build trên nền tảng Katana ( không còn dc phát triển bởi Microsoft), còn IdentityServer4 được build trên .Net Core có thể triển khai trên x-platform. Vậy nên IdentityServer4 là option tốt hơn cả.

##Client

Resource

Bao gồm IdentityResource và ApiResource

Mỗi Resource sẽ chứa các claims và qui định các scopes của nó

IdentityResource (openId, profile) chứa các claims như openId(sub), profile(name,family_name,birthdate)

Mỗi ApiResource có thể có 1 hoặc nhiều scopes (ApiScope)

Ex:

    // simple API with a single scope (in this case the scope name is the same as the api name)
    new ApiResource("api1", "Some API 1"),

    // expanded version if more control is needed
    new ApiResource
    {
        Name = "api2",

        // secret for using introspection endpoint
        ApiSecrets =
        {
            new Secret("secret".Sha256())
        },

        // include the following using claims in access token (in addition to subject id)
        UserClaims = { JwtClaimTypes.Name, JwtClaimTypes.Email }
        },

        // this API defines two scopes
        Scopes =
        {
            new Scope()
            {
                Name = "api2.full_access",
                DisplayName = "Full access to API 2",
            },
            new Scope
            {
                Name = "api2.read_only",
                DisplayName = "Read only access to API 2"
            }
        }
    }

##Scopes

Scopes: Models an OpenID Connect (Identity scopes like email, given_name etc.) or OAuth2 (Resource scopes like your WebApi that you want to protect it's data) scopes.

Scopes are at the client level, claims are at the resource's (user's) level

-> Định nghĩa Client với các scope được quyền truy cập

-> Authorite các API, resource với các scope tương ứng (policies)

-> User login (by Client app), được authorite bằng các claims tương ứng