-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathWeatherForecastController.cs
More file actions
45 lines (39 loc) · 1.35 KB
/
WeatherForecastController.cs
File metadata and controls
45 lines (39 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.Test.Common;
namespace PerformanceTestService.Controllers
{
[ApiController]
[Authorize]
[Route("SecurePage")]
public class WeatherForecastController : ControllerBase
{
private readonly ITokenAcquisition _tokenAcquisition;
public WeatherForecastController(
ITokenAcquisition tokenAcquisition)
{
_tokenAcquisition = tokenAcquisition;
}
[HttpGet(TestConstants.SecurePageGetEmpty)]
public string GetEmpty()
{
return "Success.";
}
[HttpGet(TestConstants.SecurePageGetTokenForUserAsync)]
public async Task<string> GetTokenForUserAsync()
{
return await _tokenAcquisition.GetAccessTokenForUserAsync(
TestConstants.s_userReadScope).ConfigureAwait(false);
}
[HttpGet(TestConstants.SecurePageGetTokenForAppAsync)]
public async Task<string> GetTokenForAppAsync()
{
return await _tokenAcquisition.GetAccessTokenForAppAsync(
TestConstants.s_scopeForApp).ConfigureAwait(false);
}
}
}