Installation
Installera direkt från nuget
Du kan installera direkt från nuget med följande kommando:
Install-Package IdentityServer4 -Version 4.0.4
Installera IdentityServer4 -mallar
dotnet new -i IdentityServer4.Templates
Lägg till quickui -filer och ASP.NET -identitet (valfritt)
dotnet new is4aspid --force
Uppdatera configureservices () -metoden i start.cs enligt nedan:
services.AddControllersWithViews();
Uppdatera också metoden configure () i startup.cs:
app.UseRouting();
app.UseIdentityServer();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
Bygga och driva projektet Bläddra “/.well-känd/openid-configuration” för att se till att upptäcktens slutpunkter är igång.
Kör i Docker
- Skapa ett tomt ASP.NET -kärnprojekt (kontrollera “Enable Docker Support”)
- Se till att projektfilen riktar sig till Linux OS Linux
- Ändra dockningsfilen enligt nedan:
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”\]
- Lägg till IdentityServer 4 genom att köra följande kommando:
dotnet add package IdentityServer4