-
Notifications
You must be signed in to change notification settings - Fork 239
Jmprieur/add ciam dev apps #2399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/DevApps/ciam/myWebApi/Controllers/WeatherForecastController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.Identity.Web.Resource; | ||
|
|
||
| namespace myWebApi.Controllers; | ||
|
|
||
| [Authorize] | ||
| [ApiController] | ||
| [Route("[controller]")] | ||
| [RequiredScope(RequiredScopesConfigurationKey = "AzureAd:Scopes")] | ||
| public class WeatherForecastController : ControllerBase | ||
| { | ||
| private static readonly string[] Summaries = new[] | ||
| { | ||
| "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
| }; | ||
|
|
||
| private readonly ILogger<WeatherForecastController> _logger; | ||
|
|
||
| public WeatherForecastController(ILogger<WeatherForecastController> logger) | ||
| { | ||
| _logger = logger; | ||
| } | ||
|
|
||
| [HttpGet(Name = "GetWeatherForecast")] | ||
| public IEnumerable<WeatherForecast> Get() | ||
| { | ||
| return Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
| { | ||
| Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), | ||
| TemperatureC = Random.Shared.Next(-20, 55), | ||
| Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
| }) | ||
| .ToArray(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| using Microsoft.AspNetCore.Authentication; | ||
jmprieur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
| using Microsoft.Identity.Web; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
| // Add services to the container. | ||
| builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | ||
| .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd")); | ||
|
|
||
| builder.Services.AddControllers(); | ||
| // 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(); | ||
| } | ||
|
|
||
| app.UseHttpsRedirection(); | ||
|
|
||
| app.UseAuthorization(); | ||
|
|
||
| app.MapControllers(); | ||
|
|
||
| app.Run(); | ||
31 changes: 31 additions & 0 deletions
31
tests/DevApps/ciam/myWebApi/Properties/launchSettings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/launchsettings.json", | ||
| "iisSettings": { | ||
| "windowsAuthentication": false, | ||
| "anonymousAuthentication": true, | ||
| "iisExpress": { | ||
| "applicationUrl": "http://localhost:32434", | ||
| "sslPort": 44385 | ||
| } | ||
| }, | ||
| "profiles": { | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "swagger", | ||
| "applicationUrl": "https://localhost:7082;http://localhost:5299", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "IIS Express": { | ||
| "commandName": "IISExpress", | ||
| "launchBrowser": true, | ||
| "launchUrl": "swagger", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| namespace myWebApi; | ||
|
|
||
| public class WeatherForecast | ||
| { | ||
| public DateOnly Date { get; set; } | ||
|
|
||
| public int TemperatureC { get; set; } | ||
|
|
||
| public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
|
|
||
| public string? Summary { get; set; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "AzureAd": { | ||
| "ClientId": "63e6d091-0e6d-4c8b-be67-d405e02ae3d8", | ||
| "Scopes": "access_as_user", | ||
| "CallbackPath": "/signin-oidc", | ||
| "Authority": "https://TrialTenantJmprieur.ciamlogin.com/" | ||
| }, | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| }, | ||
| "AllowedHosts": "*" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFrameworks>net7.0</TargetFrameworks> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <UserSecretsId>aspnet-myWebApi-17be892d-3bb3-4282-92e2-301b02c86ed6</UserSecretsId> | ||
| <UseWIP>true</UseWIP> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10" /> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll address this later (with the fact that it's still using IDownstreamWebApi. It's straight from the project templates) |
||
| <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(UseWIP)' == 'false' "> | ||
| <PackageReference Include="Microsoft.Identity.Web" Version="2.13.3" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(UseWIP)' == 'true' "> | ||
| <ProjectReference Include="..\..\..\..\src\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| @page | ||
| @model ErrorModel | ||
| @{ | ||
| ViewData["Title"] = "Error"; | ||
| } | ||
|
|
||
| <h1 class="text-danger">Error.</h1> | ||
| <h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
|
||
| @if (Model.ShowRequestId) | ||
| { | ||
| <p> | ||
| <strong>Request ID:</strong> <code>@Model.RequestId</code> | ||
| </p> | ||
| } | ||
|
|
||
| <h3>Development Mode</h3> | ||
| <p> | ||
| Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. | ||
| </p> | ||
| <p> | ||
| <strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
| It can result in displaying sensitive information from exceptions to end users. | ||
| For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
| and restarting the app. | ||
| </p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| using System.Diagnostics; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
|
||
| namespace myWebApp.Pages; | ||
|
|
||
| [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
| [IgnoreAntiforgeryToken] | ||
| public class ErrorModel : PageModel | ||
| { | ||
| public string? RequestId { get; set; } | ||
|
|
||
| public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
|
||
| private readonly ILogger<ErrorModel> _logger; | ||
|
|
||
| public ErrorModel(ILogger<ErrorModel> logger) | ||
| { | ||
| _logger = logger; | ||
| } | ||
|
|
||
| public void OnGet() | ||
| { | ||
| RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| @page | ||
| @model IndexModel | ||
| @{ | ||
| ViewData["Title"] = "Home page"; | ||
| } | ||
|
|
||
| <div class="text-center"> | ||
| <h1 class="display-4">Welcome</h1> | ||
| <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> | ||
| </div> | ||
|
|
||
| <div>Api result</div> | ||
|
|
||
| <div>@ViewData["ApiResult"]</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.