Instalasi

Instal langsung dari Nuget

Anda dapat menginstal langsung dari Nuget menggunakan perintah berikut:

    Install-Package IdentityServer4 -Version 4.0.4

Instal Template IdentityServer4

    dotnet new -i IdentityServer4.Templates  

Tambahkan file QuickUI dan identitas ASP.NET (opsional)

    dotnet new is4aspid --force  

Update configureServices () Metode di startup.cs seperti di bawah ini:

    services.AddControllersWithViews();  

Perbarui metode konfigurasi () di startup.cs:

    app.UseRouting();  
       
     app.UseIdentityServer();  
     app.UseAuthorization();   
     app.UseEndpoints(endpoints =>  
     {  
     endpoints.MapControllerRoute(  
     name: "default",  
     pattern: "{controller=Home}/{action=Index}/{id?}");  
     });  

Membangun dan menjalankan proyek Jelajahi “/.well-known/openid-konfigurasi” untuk memastikan titik akhir penemuan sedang berjalan dan berjalan.

Berlari di Docker

  1. Buat proyek inti ASP.NET kosong (periksa ‘Aktifkan Dukungan Docker”)
  2. Pastikan file proyek menargetkan Linux OS Linux
  3. Ubah file Docker seperti di bawah ini:
        FROM microsoft/dotnet:2.2-runtime AS base  
        WORKDIR /app  
        EXPOSE 80  
        EXPOSE 443  
           
        FROM microsoft/dotnet:2.2-sdk AS build  
        WORKDIR /src  
        COPY \[“JrTech.Identity.Web/JrTech.Identity.Web.csproj“, “JrTech.Identity.Web/”\]  
        RUN dotnet restore “JrTech.Identity.Web/JrTech.Identity.Web.csproj“  
        COPY . .  
        WORKDIR “/src/JrTech.Identity.Web”  
        RUN dotnet build “JrTech.Identity.Web.csproj” -c Release -o /app  
           
        FROM build AS publish  
        RUN dotnet publish “JrTech.Identity.Web.csproj” -c Release -o /app  
           
        FROM base AS final  
        WORKDIR /app  
        COPY –from=publish /app .  
        ENTRYPOINT \[“dotnet”, “JrTech.Identity.Web.dll”\]  
  • Tambahkan IdentityServer 4 dengan menjalankan perintah berikut:
    dotnet add package IdentityServer4
 Indonesia