Skip to content

Commit cc077ff

Browse files
WIP
1 parent 731cf64 commit cc077ff

81 files changed

Lines changed: 586 additions & 234 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/IdServer/SimpleIdServer.IdServer.Email/UI/RegisterController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public RegisterController(
3030
IConfiguration configuration,
3131
IEmailUserNotificationService userNotificationService,
3232
ITokenRepository tokenRepository,
33-
IJwtBuilder jwtBuilder) : base(options, distributedCache, userRepository, transactionBuilder, otpAuthenticators, configuration, userNotificationService, tokenRepository, jwtBuilder)
33+
IJwtBuilder jwtBuilder,
34+
IRealmStore realmStore) : base(options, distributedCache, userRepository, transactionBuilder, otpAuthenticators, configuration, userNotificationService, tokenRepository, jwtBuilder, realmStore)
3435
{
3536
_authenticationHelper = authenticationHelper;
3637
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) SimpleIdServer. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace SimpleIdServer.IdServer.Helpers;
5+
6+
public interface IRealmStore
7+
{
8+
string Realm { get; set; }
9+
}
10+
11+
public class RealmStore : IRealmStore
12+
{
13+
public string Realm { get; set; }
14+
}

src/IdServer/SimpleIdServer.IdServer.Helpers/RealmContext.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/IdServer/SimpleIdServer.IdServer.Pwd/UI/RegisterController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public RegisterController(
2323
IUserRepository userRepository,
2424
ITokenRepository tokenRepository,
2525
ITransactionBuilder transactionBuilder,
26-
IJwtBuilder jwtBuilder) : base(options, distributedCache, userRepository, tokenRepository, transactionBuilder, jwtBuilder)
26+
IJwtBuilder jwtBuilder,
27+
IRealmStore realmStore) : base(options, distributedCache, userRepository, tokenRepository, transactionBuilder, jwtBuilder, realmStore)
2728
{
2829
}
2930

src/IdServer/SimpleIdServer.IdServer.Sms/UI/RegisterController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public RegisterController(
3333
ISmsUserNotificationService userNotificationService,
3434
ITokenRepository tokenRepository,
3535
ITransactionBuilder transactionBuilder,
36-
IJwtBuilder jwtBuilder) : base(options, distributedCache, userRepository, transactionBuilder, otpAuthenticators, configuration, userNotificationService, tokenRepository, jwtBuilder)
36+
IJwtBuilder jwtBuilder,
37+
IRealmStore realmStore) : base(options, distributedCache, userRepository, transactionBuilder, otpAuthenticators, configuration, userNotificationService, tokenRepository, jwtBuilder, realmStore)
3738
{
3839
_authenticationHelper = authenticationHelper;
3940
}

src/IdServer/SimpleIdServer.IdServer.VerifiablePresentation/Apis/VpRegisterController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.Extensions.Logging;
77
using SimpleIdServer.IdServer.Api;
88
using SimpleIdServer.IdServer.Exceptions;
9+
using SimpleIdServer.IdServer.Helpers;
910
using SimpleIdServer.IdServer.Jwt;
1011
using SimpleIdServer.IdServer.Options;
1112
using SimpleIdServer.IdServer.Stores;
@@ -22,13 +23,15 @@ public class VpRegisterController : BaseController
2223
private readonly IDistributedCache _distributedCache;
2324
private readonly IUserRepository _userRepository;
2425
private readonly ITransactionBuilder _transactionBuilder;
26+
private readonly IRealmStore _realmStore;
2527
private readonly IdServerHostOptions _idServerHostOptions;
2628
private readonly ILogger<VpRegisterController> _logger;
2729

2830
public VpRegisterController(
2931
IDistributedCache distributedCache,
3032
IUserRepository userRepository,
3133
ITransactionBuilder transactionBuilder,
34+
IRealmStore realmStore,
3235
Microsoft.Extensions.Options.IOptions<IdServerHostOptions> idServerHostOptions,
3336
ILogger<VpRegisterController> logger,
3437
ITokenRepository tokenRepository,
@@ -37,6 +40,7 @@ public VpRegisterController(
3740
_distributedCache = distributedCache;
3841
_userRepository = userRepository;
3942
_transactionBuilder = transactionBuilder;
43+
_realmStore = realmStore;
4044
_idServerHostOptions = idServerHostOptions.Value;
4145
_logger = logger;
4246
}
@@ -124,7 +128,7 @@ protected async Task<VpEndRegisterResult> CreateUser(string issuer,
124128

125129
private async Task<UserRegistrationProgress> GetRegistrationProgress()
126130
{
127-
var cookieName = _idServerHostOptions.GetRegistrationCookieName();
131+
var cookieName = _idServerHostOptions.GetRegistrationCookieName(_realmStore.Realm);
128132
if (!Request.Cookies.ContainsKey(cookieName)) return null;
129133
var cookieValue = Request.Cookies[cookieName];
130134
var json = await _distributedCache.GetStringAsync(cookieValue);

src/IdServer/SimpleIdServer.IdServer.VerifiablePresentation/UI/RegisterController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.Extensions.Caching.Distributed;
77
using Microsoft.Extensions.Options;
88
using SimpleIdServer.IdServer.Domains;
9+
using SimpleIdServer.IdServer.Helpers;
910
using SimpleIdServer.IdServer.Jwt;
1011
using SimpleIdServer.IdServer.Options;
1112
using SimpleIdServer.IdServer.Stores;
@@ -26,7 +27,8 @@ public RegisterController(
2627
IUserRepository userRepository,
2728
ITokenRepository tokenRepository,
2829
ITransactionBuilder transactionBuilder,
29-
IJwtBuilder jwtBuilder) : base(options, distributedCache, userRepository, tokenRepository, transactionBuilder, jwtBuilder)
30+
IJwtBuilder jwtBuilder,
31+
IRealmStore realmStore) : base(options, distributedCache, userRepository, tokenRepository, transactionBuilder, jwtBuilder, realmStore)
3032
{
3133
_presentationDefinitionStore = presentationDefinitionStore;
3234
}

src/IdServer/SimpleIdServer.IdServer.Website/Controllers/LoginController.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ public LoginController(
2828
_logger = logger;
2929
}
3030

31+
[Route("auth")]
32+
public IActionResult Index(string returnUrl)
33+
{
34+
var props = new AuthenticationProperties
35+
{
36+
RedirectUri = returnUrl
37+
};
38+
return Challenge(props, "oidc");
39+
}
40+
3141
[Route("login")]
3242
public IActionResult Login(string acrValues, string realm = null)
3343
{

src/IdServer/SimpleIdServer.IdServer.Website/Controllers/LogoutController.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
using Microsoft.Extensions.Caching.Distributed;
88
using Microsoft.Extensions.Options;
99
using Microsoft.IdentityModel.JsonWebTokens;
10+
using SimpleIdServer.IdServer.Helpers;
1011

1112
namespace SimpleIdServer.IdServer.Website.Controllers
1213
{
1314
public class LogoutController : Controller
1415
{
1516
private readonly IDistributedCache _distributedCache;
17+
private readonly IRealmStore _realmStore;
1618
private readonly IdServerWebsiteOptions _options;
1719

18-
public LogoutController(IDistributedCache distributedCache, IOptions<IdServerWebsiteOptions> options)
20+
public LogoutController(IDistributedCache distributedCache, IRealmStore realmStore, IOptions<IdServerWebsiteOptions> options)
1921
{
2022
_distributedCache = distributedCache;
23+
_realmStore = realmStore;
2124
_options = options.Value;
2225
}
2326

@@ -35,7 +38,7 @@ public IActionResult SignOut()
3538
public IActionResult OidcSignoutCallback()
3639
{
3740
var redirectUri = "~/";
38-
if (_options.IsReamEnabled) redirectUri = $"~/{IdServer.Helpers.RealmContext.Instance().Realm}/clients";
41+
if (_options.IsReamEnabled) redirectUri = $"~/{_realmStore.Realm}/clients";
3942
return SignOut(new AuthenticationProperties
4043
{
4144
RedirectUri = Url.Content(redirectUri)

src/IdServer/SimpleIdServer.IdServer.Website/Helpers/UrlHelper.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
using Microsoft.Extensions.Options;
5+
using SimpleIdServer.IdServer.Helpers;
56

67
namespace SimpleIdServer.IdServer.Website.Helpers;
78

@@ -13,16 +14,17 @@ public interface IUrlHelper
1314
public class UrlHelper : IUrlHelper
1415
{
1516
private readonly IdServerWebsiteOptions _options;
17+
private readonly IRealmStore _realmStore;
1618

17-
public UrlHelper(IOptions<IdServerWebsiteOptions> options)
19+
public UrlHelper(IOptions<IdServerWebsiteOptions> options, IRealmStore realmStore)
1820
{
1921
_options = options.Value;
22+
_realmStore = realmStore;
2023
}
2124

2225
public string GetUrl(string url)
2326
{
2427
if (!_options.IsReamEnabled) return url;
25-
var realmContext = IdServer.Helpers.RealmContext.Instance();
26-
return string.IsNullOrWhiteSpace(realmContext.Realm) ? url : $"/{realmContext.Realm}{url}";
28+
return string.IsNullOrWhiteSpace(_realmStore.Realm) ? url : $"/{_realmStore.Realm}{url}";
2729
}
2830
}

0 commit comments

Comments
 (0)