安装
直接从Nuget安装
您可以使用以下命令直接从Nuget安装:
Install-Package IdentityServer4 -Version 4.0.4
安装IdentityServer4模板
dotnet new -i IdentityServer4.Templates
添加QuickUI文件和ASP.NET身份(可选)
dotnet new is4aspid --force
startup.cs中的更新configureservices()方法如下:
services.AddControllersWithViews();
还在startup.cs中更新configure()方法:
app.UseRouting();
app.UseIdentityServer();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
建立和运行项目 浏览“ /.well-nown/openid-configuration”,以确保发现端点启动并运行。
在Docker中跑步
1.创建一个空的ASP.NET核心项目(检查“启用Docker支持”) 2.确保项目文件针对Linux OS Linux 3.修改Docker文件如下:
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”\]
*通过运行以下命令添加IdentityServer 4:
dotnet add package IdentityServer4