Cài đặt
Cài đặt trực tiếp từ Nuget
Bạn có thể cài đặt trực tiếp từ NUGET bằng lệnh sau:
Install-Package IdentityServer4 -Version 4.0.4
Cài đặt Mẫu danh tínhServer4
dotnet new -i IdentityServer4.Templates
Thêm các tệp Quickui và Nhận dạng ASP.NET (Tùy chọn)
dotnet new is4aspid --force
Cập nhật Phương thức ConfigureService () trong startup.cs như dưới đây:
services.AddControllersWithViews();
Cập nhật phương thức Cấu hình () trong startup.cs:
app.UseRouting();
app.UseIdentityServer();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
Xây dựng và điều hành dự án Duyệt qua /.well-unders/openid-configuration, để đảm bảo các điểm cuối khám phá đang hoạt động.
Chạy trong Docker
- Tạo một dự án ASP.NET Core trống (kiểm tra ‘Kích hoạt Docker Support,)
- Đảm bảo tệp dự án nhắm mục tiêu Linux OS Linux
- Sửa đổi tệp Docker như dưới đây:
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”\]
- Thêm IndentityServer 4 bằng cách chạy lệnh sau:
dotnet add package IdentityServer4