Добавьте файлы проекта.
This commit is contained in:
24
Yuna.OauthServer/Dockerfile
Normal file
24
Yuna.OauthServer/Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Yuna.OauthServer/Yuna.OauthServer.csproj", "Yuna.OauthServer/"]
|
||||
RUN dotnet restore "./Yuna.OauthServer/Yuna.OauthServer.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Yuna.OauthServer"
|
||||
RUN dotnet build "./Yuna.OauthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Yuna.OauthServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Yuna.OauthServer.dll"]
|
19
Yuna.OauthServer/Endpoints/Auth/AuthEndpoints.cs
Normal file
19
Yuna.OauthServer/Endpoints/Auth/AuthEndpoints.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yuna.OauthServer.Endpoints.Auth.DTO;
|
||||
|
||||
namespace Yuna.OauthServer.Endpoints.Auth
|
||||
{
|
||||
public class AuthEndpoints
|
||||
{
|
||||
public void Define(WebApplication app)
|
||||
{
|
||||
app.MapGet("oauth/auth", Authorize)
|
||||
}
|
||||
|
||||
public IResult Authorize([AsParameters] AuthRequest request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
14
Yuna.OauthServer/Endpoints/Auth/DTO/AuthRequest.cs
Normal file
14
Yuna.OauthServer/Endpoints/Auth/DTO/AuthRequest.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yuna.OauthServer.Endpoints.Auth.DTO
|
||||
{
|
||||
|
||||
public class AuthRequest
|
||||
{
|
||||
public string response_type { get; set; } = null!;
|
||||
public string client_id { get; set; } = null!;
|
||||
public string redirect_uri { get; set; } = null!;
|
||||
|
||||
}
|
||||
}
|
9
Yuna.OauthServer/Endpoints/Auth/DTO/AuthResponse.cs
Normal file
9
Yuna.OauthServer/Endpoints/Auth/DTO/AuthResponse.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Yuna.OauthServer.Endpoints.Auth.DTO
|
||||
{
|
||||
public class AuthResponse
|
||||
{
|
||||
public string ResponseType { get;} = "code";
|
||||
public string Code { get; set; } = null!;
|
||||
public string RedirectUri { get; set; } = null!;
|
||||
}
|
||||
}
|
25
Yuna.OauthServer/Model/Client.cs
Normal file
25
Yuna.OauthServer/Model/Client.cs
Normal file
@ -0,0 +1,25 @@
|
||||
namespace Yuna.OauthServer.Model
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
|
||||
public Client(string clientName, int clientId, string secret, string clientUri, string redirectUri)
|
||||
{
|
||||
ClientName = clientName;
|
||||
ClientId = clientId;
|
||||
ClientSecret = secret;
|
||||
ClientUri = clientUri;
|
||||
RedirectUri = redirectUri;
|
||||
}
|
||||
|
||||
public string ClientName { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
//public string ClientType { get; set; }
|
||||
//public List<string> GrantType { get; set; }
|
||||
public bool IsActive { get; set; } = false;
|
||||
//public List<string> AllowedScopes { get; set; }
|
||||
public string? ClientUri { get; set; }
|
||||
public string RedirectUri { get; set; }
|
||||
}
|
||||
}
|
5
Yuna.OauthServer/Model/GrantType.cs
Normal file
5
Yuna.OauthServer/Model/GrantType.cs
Normal file
@ -0,0 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yuna.OauthServer.Model
|
||||
{
|
||||
}
|
42
Yuna.OauthServer/Program.cs
Normal file
42
Yuna.OauthServer/Program.cs
Normal file
@ -0,0 +1,42 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
})
|
||||
.WithName("GetWeatherForecast")
|
||||
.WithOpenApi();
|
||||
|
||||
app.Run();
|
||||
|
||||
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
40
Yuna.OauthServer/Properties/launchSettings.json
Normal file
40
Yuna.OauthServer/Properties/launchSettings.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5026"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:47304",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
}
|
12
Yuna.OauthServer/Storage/ClientsList.cs
Normal file
12
Yuna.OauthServer/Storage/ClientsList.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Yuna.OauthServer.Model;
|
||||
|
||||
namespace Yuna.OauthServer.Storage
|
||||
{
|
||||
public class ClientsList
|
||||
{
|
||||
public List<Client> Clients = new()
|
||||
{
|
||||
new Client("yandex", 0, "5aS3dFgH7jK9lM1nO5pQrT",)
|
||||
}
|
||||
}
|
||||
}
|
17
Yuna.OauthServer/Yuna.OauthServer.csproj
Normal file
17
Yuna.OauthServer/Yuna.OauthServer.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.0-preview1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
Yuna.OauthServer/Yuna.OauthServer.http
Normal file
6
Yuna.OauthServer/Yuna.OauthServer.http
Normal file
@ -0,0 +1,6 @@
|
||||
@Yuna.OauthServer_HostAddress = http://localhost:5026
|
||||
|
||||
GET {{Yuna.OauthServer_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
8
Yuna.OauthServer/appsettings.Development.json
Normal file
8
Yuna.OauthServer/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
Yuna.OauthServer/appsettings.json
Normal file
9
Yuna.OauthServer/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
Reference in New Issue
Block a user