Skip to content

Commit 44b669e

Browse files
committed
Updating namespaces
1 parent ff782d2 commit 44b669e

18 files changed

Lines changed: 1984 additions & 2052 deletions

content/StsServerIdentity/Controllers/AccountController.cs

Lines changed: 603 additions & 604 deletions
Large diffs are not rendered by default.

content/StsServerIdentity/Controllers/ConsentController.cs

Lines changed: 195 additions & 196 deletions
Large diffs are not rendered by default.

content/StsServerIdentity/Controllers/DeviceController.cs

Lines changed: 173 additions & 174 deletions
Large diffs are not rendered by default.

content/StsServerIdentity/Controllers/GrantsController.cs

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,86 +10,85 @@
1010
using StsServerIdentity.Filters;
1111
using StsServerIdentity.Models;
1212

13-
namespace StsServerIdentity.Controllers
13+
namespace StsServerIdentity.Controllers;
14+
15+
/// <summary>
16+
/// This sample controller allows a user to revoke grants given to clients
17+
/// </summary>
18+
[SecurityHeaders]
19+
[Authorize]
20+
public class GrantsController : Controller
1421
{
22+
private readonly IIdentityServerInteractionService _interaction;
23+
private readonly IClientStore _clients;
24+
private readonly IResourceStore _resources;
25+
private readonly IEventService _events;
26+
27+
public GrantsController(IIdentityServerInteractionService interaction,
28+
IClientStore clients,
29+
IResourceStore resources,
30+
IEventService events)
31+
{
32+
_interaction = interaction;
33+
_clients = clients;
34+
_resources = resources;
35+
_events = events;
36+
}
37+
1538
/// <summary>
16-
/// This sample controller allows a user to revoke grants given to clients
39+
/// Show list of grants
1740
/// </summary>
18-
[SecurityHeaders]
19-
[Authorize]
20-
public class GrantsController : Controller
41+
[HttpGet]
42+
public async Task<IActionResult> Index()
2143
{
22-
private readonly IIdentityServerInteractionService _interaction;
23-
private readonly IClientStore _clients;
24-
private readonly IResourceStore _resources;
25-
private readonly IEventService _events;
26-
27-
public GrantsController(IIdentityServerInteractionService interaction,
28-
IClientStore clients,
29-
IResourceStore resources,
30-
IEventService events)
31-
{
32-
_interaction = interaction;
33-
_clients = clients;
34-
_resources = resources;
35-
_events = events;
36-
}
44+
return View("Index", await BuildViewModelAsync());
45+
}
3746

38-
/// <summary>
39-
/// Show list of grants
40-
/// </summary>
41-
[HttpGet]
42-
public async Task<IActionResult> Index()
43-
{
44-
return View("Index", await BuildViewModelAsync());
45-
}
47+
/// <summary>
48+
/// Handle postback to revoke a client
49+
/// </summary>
50+
[HttpPost]
51+
[ValidateAntiForgeryToken]
52+
public async Task<IActionResult> Revoke(string clientId)
53+
{
54+
await _interaction.RevokeUserConsentAsync(clientId);
55+
await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), clientId));
4656

47-
/// <summary>
48-
/// Handle postback to revoke a client
49-
/// </summary>
50-
[HttpPost]
51-
[ValidateAntiForgeryToken]
52-
public async Task<IActionResult> Revoke(string clientId)
53-
{
54-
await _interaction.RevokeUserConsentAsync(clientId);
55-
await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), clientId));
57+
return RedirectToAction("Index");
58+
}
5659

57-
return RedirectToAction("Index");
58-
}
60+
private async Task<GrantsViewModel> BuildViewModelAsync()
61+
{
62+
var grants = await _interaction.GetAllUserGrantsAsync();
5963

60-
private async Task<GrantsViewModel> BuildViewModelAsync()
64+
var list = new List<GrantViewModel>();
65+
foreach (var grant in grants)
6166
{
62-
var grants = await _interaction.GetAllUserGrantsAsync();
63-
64-
var list = new List<GrantViewModel>();
65-
foreach (var grant in grants)
67+
var client = await _clients.FindClientByIdAsync(grant.ClientId);
68+
if (client != null)
6669
{
67-
var client = await _clients.FindClientByIdAsync(grant.ClientId);
68-
if (client != null)
69-
{
70-
var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes);
70+
var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes);
7171

72-
var item = new GrantViewModel()
73-
{
74-
ClientId = client.ClientId,
75-
ClientName = client.ClientName ?? client.ClientId,
76-
ClientLogoUrl = client.LogoUri,
77-
ClientUrl = client.ClientUri,
78-
Description = grant.Description,
79-
Created = grant.CreationTime,
80-
Expires = grant.Expiration,
81-
IdentityGrantNames = resources.IdentityResources.Select(x => x.DisplayName ?? x.Name).ToArray(),
82-
ApiGrantNames = resources.ApiScopes.Select(x => x.DisplayName ?? x.Name).ToArray()
83-
};
72+
var item = new GrantViewModel()
73+
{
74+
ClientId = client.ClientId,
75+
ClientName = client.ClientName ?? client.ClientId,
76+
ClientLogoUrl = client.LogoUri,
77+
ClientUrl = client.ClientUri,
78+
Description = grant.Description,
79+
Created = grant.CreationTime,
80+
Expires = grant.Expiration,
81+
IdentityGrantNames = resources.IdentityResources.Select(x => x.DisplayName ?? x.Name).ToArray(),
82+
ApiGrantNames = resources.ApiScopes.Select(x => x.DisplayName ?? x.Name).ToArray()
83+
};
8484

85-
list.Add(item);
86-
}
85+
list.Add(item);
8786
}
88-
89-
return new GrantsViewModel
90-
{
91-
Grants = list
92-
};
9387
}
88+
89+
return new GrantsViewModel
90+
{
91+
Grants = list
92+
};
9493
}
9594
}

content/StsServerIdentity/Controllers/HomeController.cs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,37 @@
33
using IdentityServer4.Services;
44
using StsServerIdentity.Models;
55

6-
namespace StsServerIdentity.Controllers
6+
namespace StsServerIdentity.Controllers;
7+
8+
public class HomeController : Controller
79
{
8-
public class HomeController : Controller
10+
private readonly IIdentityServerInteractionService _interaction;
11+
12+
public HomeController(IIdentityServerInteractionService interaction)
913
{
10-
private readonly IIdentityServerInteractionService _interaction;
14+
_interaction = interaction;
15+
}
1116

12-
public HomeController(IIdentityServerInteractionService interaction)
13-
{
14-
_interaction = interaction;
15-
}
17+
public IActionResult Index()
18+
{
19+
return View();
20+
}
1621

17-
public IActionResult Index()
18-
{
19-
return View();
20-
}
2122

23+
/// <summary>
24+
/// Shows the error page
25+
/// </summary>
26+
public async Task<IActionResult> Error(string errorId)
27+
{
28+
var vm = new ErrorViewModel();
2229

23-
/// <summary>
24-
/// Shows the error page
25-
/// </summary>
26-
public async Task<IActionResult> Error(string errorId)
30+
// retrieve error details from identityserver
31+
var message = await _interaction.GetErrorContextAsync(errorId);
32+
if (message != null)
2733
{
28-
var vm = new ErrorViewModel();
29-
30-
// retrieve error details from identityserver
31-
var message = await _interaction.GetErrorContextAsync(errorId);
32-
if (message != null)
33-
{
34-
vm.Error = message;
35-
}
36-
37-
return View("Error", vm);
34+
vm.Error = message;
3835
}
36+
37+
return View("Error", vm);
3938
}
40-
}
39+
}

0 commit comments

Comments
 (0)