Skip to content

Commit 8c36113

Browse files
committed
Merge tag '0.5.3' into develop
0.5.3
2 parents 3008154 + 62b54a0 commit 8c36113

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/WebAppTest/Controllers/Models/ClientFlowDto.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ public class ClientFlowDto
44
{
55
public string Email { get; set; }
66
}
7+
8+
public class CodeFlowDto
9+
{
10+
public string? Scope { get; set; }
11+
}
712
}

src/WebAppTest/Controllers/OAuth2Controller.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
using DotNetCoreOAuth2;
22
using MailKit;
33
using MailKit.Net.Imap;
4-
using MailKit.Search;
54
using MailKit.Security;
65
using Microsoft.AspNetCore.Mvc;
76
using Microsoft.Extensions.Options;
87
using Newtonsoft.Json;
98
using System.Text;
10-
using WebAppTest.Support;
119

1210
namespace WebAppTest.Controllers
1311
{

src/WebAppTest/Controllers/SampleIMAPController.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,24 @@ public IActionResult Index()
4444

4545
[Route("code-flow")]
4646
[HttpPost]
47-
public async Task<IActionResult> CodeFlow()
47+
public async Task<IActionResult> CodeFlow(CodeFlowDto dto)
4848
{
4949
OAuth2Client oAuth2Client = CreateOAuth2Client();
5050

51+
var clientScope = dto?.Scope ?? "openid email offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send";
52+
5153
var relativeUrl = Url.Action("GetToken", "SampleIMAP")!;
5254
var redirectUrl = $"{Request.Scheme}://{Request.Host}{Request.PathBase}/{relativeUrl.TrimStart('/')}";
5355
var customState = Guid.NewGuid().ToString();
5456
var codeChallengeUrl = await oAuth2Client.GenerateUrlForCodeFlowAsync(
55-
"openid email offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send",
57+
clientScope,
5658
redirectUrl,
5759
new Dictionary<string, string>(),
5860
customState: customState);
5961

6062
// In a real world, this will return a redirect to the code challenge url so that
6163
// the user will be immediately prompted with a login page.
62-
var model = new ();
64+
var model = new SampleIMAPModel();
6365
model.State = customState;
6466
model.LoginLink = codeChallengeUrl.AbsoluteUri;
6567
model.DebugLoginLink = DumpUrl(model.LoginLink);

src/WebAppTest/Views/SampleIMAP/Index.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636

3737
<h2>IMAP with code flow</h2>
3838
<form action="/sample-oauth2/code-flow" method="post">
39-
39+
<label for="scop">Scope:</label>
40+
<input style="width: 800px" type="text" id="scope" name="scope" value="openid email offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send" />
4041
<input type="submit" value="Generate code flow link" />
4142
</form>
4243
}

0 commit comments

Comments
 (0)