Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 56 additions & 15 deletions ResourceServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Authlete.Api;
using Authlete.Conf;
using Microsoft.AspNetCore.Hosting;

// Initialize a WebApplication builder with the provided command-line arguments
var builder = WebApplication.CreateBuilder(args);

namespace ResourceServer
// Configure the WebHost to listen on all network interfaces on port 5001
builder.WebHost.UseUrls("http://*:5001");

// Adds controllers to the services collection.
// This is required to use MVC controller features in .NET 8.0, replacing the older AddMvc.
builder.Services.AddControllers();

// Adds a singleton service of type IAuthleteApi. This is a custom setup for integrating Authlete,
// a service for OAuth 2.0 and OpenID Connect 1.0 implementation.
// It uses a specific configuration loader 'AuthletePropertiesConfiguration'
// assumed to load necessary settings for Authlete.
builder.Services.AddSingleton<IAuthleteApi>(provider =>
{
// Create a configuration instance
var conf = new AuthletePropertiesConfiguration();
// Return a new instance of AuthleteApi with the loaded configuration
return new AuthleteApi(conf);
});

// Build the WebApplication instance using the configured builder
var app = builder.Build();

// Configure the HTTP request pipeline
if (app.Environment.IsDevelopment())
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://*:5001")
.UseStartup<Startup>()
.Build();
}
// Use the Developer Exception Page middleware during development
// for detailed exception stack traces
app.UseDeveloperExceptionPage();
}

// Middleware to serve default files.
// It will search for default files like index.html in the wwwroot folder.
app.UseDefaultFiles();

// Middleware to serve static files. Allows serving files from wwwroot folder.
app.UseStaticFiles();

// Setup endpoint routing, necessary for ASP.NET Core 3.0 onwards for routing HTTP requests
app.UseRouting();

// Configures endpoints for MVC controller actions.
// It maps incoming requests to controller actions.
app.UseEndpoints(endpoints =>
{
// Setup routing to map requests to controller actions
endpoints.MapControllers();
});

// Run the application
app.Run();

5 changes: 2 additions & 3 deletions ResourceServer/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55556/",
"applicationUrl": "http://localhost:55556",
"sslPort": 0
}
},
Expand All @@ -19,11 +19,10 @@
"ResourceServer": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000/"
"applicationUrl": "http://localhost:5001"
}
}
}
10 changes: 2 additions & 8 deletions ResourceServer/ResourceServer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -10,13 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.WebApiCompatShim" Version="2.0.1" />
<PackageReference Include="Authlete.Authlete" Version="1.0.7" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
<PackageReference Include="Authlete.Authlete" Version="1.5.0" />
</ItemGroup>

</Project>
101 changes: 0 additions & 101 deletions ResourceServer/Startup.cs

This file was deleted.