Skip to content

Commit defb101

Browse files
Add project files.
1 parent ec88f53 commit defb101

9 files changed

+198
-0
lines changed

TrevalApI.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32112.339
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrevalApI", "TrevalApI\TrevalApI.csproj", "{D2588B90-DDA9-49F9-9A68-7FDA992DF445}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D2588B90-DDA9-49F9-9A68-7FDA992DF445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D2588B90-DDA9-49F9-9A68-7FDA992DF445}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D2588B90-DDA9-49F9-9A68-7FDA992DF445}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D2588B90-DDA9-49F9-9A68-7FDA992DF445}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {9A31845C-3220-4835-9FFE-615EACAC8B85}
24+
EndGlobalSection
25+
EndGlobal

TrevalApI/.config/dotnet-tools.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"microsoft.dotnet-msidentity": {
6+
"version": "1.0.0",
7+
"commands": [
8+
"dotnet-msidentity"
9+
]
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Identity.Web.Resource;
4+
5+
namespace TrevalApI.Controllers
6+
{
7+
[Authorize]
8+
[ApiController]
9+
[Route("[controller]")]
10+
[RequiredScope(RequiredScopesConfigurationKey = "AzureAd:Scopes")]
11+
public class WeatherForecastController : ControllerBase
12+
{
13+
private static readonly string[] Summaries = new[]
14+
{
15+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
16+
};
17+
18+
private readonly ILogger<WeatherForecastController> _logger;
19+
20+
public WeatherForecastController(ILogger<WeatherForecastController> logger)
21+
{
22+
_logger = logger;
23+
}
24+
25+
[HttpGet(Name = "GetWeatherForecast")]
26+
public IEnumerable<WeatherForecast> Get()
27+
{
28+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
29+
{
30+
Date = DateTime.Now.AddDays(index),
31+
TemperatureC = Random.Shared.Next(-20, 55),
32+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
33+
})
34+
.ToArray();
35+
}
36+
}
37+
}

TrevalApI/Program.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Authentication;
2+
using Microsoft.AspNetCore.Authentication.JwtBearer;
3+
using Microsoft.Identity.Web;
4+
5+
var builder = WebApplication.CreateBuilder(args);
6+
7+
// Add services to the container.
8+
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
9+
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));
10+
11+
builder.Services.AddControllers();
12+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
13+
builder.Services.AddEndpointsApiExplorer();
14+
builder.Services.AddSwaggerGen();
15+
16+
var app = builder.Build();
17+
18+
// Configure the HTTP request pipeline.
19+
if (app.Environment.IsDevelopment())
20+
{
21+
app.UseSwagger();
22+
app.UseSwaggerUI();
23+
}
24+
25+
app.UseHttpsRedirection();
26+
27+
app.UseAuthentication();
28+
app.UseAuthorization();
29+
30+
app.MapControllers();
31+
32+
app.Run();
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:38522",
8+
"sslPort": 44357
9+
}
10+
},
11+
"profiles": {
12+
"TrevalApI": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"launchUrl": "swagger",
17+
"applicationUrl": "https://localhost:7174;http://localhost:5174",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
22+
"IIS Express": {
23+
"commandName": "IISExpress",
24+
"launchBrowser": true,
25+
"launchUrl": "swagger",
26+
"environmentVariables": {
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
}
29+
}
30+
}
31+
}

TrevalApI/TrevalApI.csproj

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<UserSecretsId>aspnet-TrevalApI-CA8445F3-3425-4CD0-9701-FCBA3C6DF4FD</UserSecretsId>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
12+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.1" />
13+
<PackageReference Include="Microsoft.Identity.Web" Version="1.16.0"/>
14+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
15+
</ItemGroup>
16+
17+
</Project>

TrevalApI/WeatherForecast.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace TrevalApI
2+
{
3+
public class WeatherForecast
4+
{
5+
public DateTime Date { get; set; }
6+
7+
public int TemperatureC { get; set; }
8+
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10+
11+
public string? Summary { get; set; }
12+
}
13+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}

TrevalApI/appsettings.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
/*
3+
The following identity settings need to be configured
4+
before the project can be successfully executed.
5+
For more info see https://aka.ms/dotnet-template-ms-identity-platform
6+
*/
7+
"AzureAd": {
8+
"Instance": "https://login.microsoftonline.com/",
9+
"Domain": "qualified.domain.name",
10+
"TenantId": "22222222-2222-2222-2222-222222222222",
11+
"ClientId": "11111111-1111-1111-11111111111111111",
12+
13+
"Scopes": "access_as_user",
14+
"CallbackPath": "/signin-oidc"
15+
},
16+
"Logging": {
17+
"LogLevel": {
18+
"Default": "Information",
19+
"Microsoft.AspNetCore": "Warning"
20+
}
21+
},
22+
"AllowedHosts": "*"
23+
}

0 commit comments

Comments
 (0)