Добавьте файлы проекта.

This commit is contained in:
2024-07-10 20:19:26 +07:00
parent 212a005438
commit e3c69229ad
74 changed files with 5674 additions and 0 deletions

View 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"]

View 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)
{
}
}
}

View 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!;
}
}

View 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!;
}
}

View 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; }
}
}

View File

@ -0,0 +1,5 @@
using System.Text.Json.Serialization;
namespace Yuna.OauthServer.Model
{
}

View 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);
}

View 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
}
}
}

View 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",)
}
}
}

View 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>

View File

@ -0,0 +1,6 @@
@Yuna.OauthServer_HostAddress = http://localhost:5026
GET {{Yuna.OauthServer_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}