Skip to content

Commit 1e24138

Browse files
Support credential issuer
1 parent 581793b commit 1e24138

7 files changed

Lines changed: 9 additions & 16 deletions

File tree

src/CredentialIssuer/SimpleIdServer.CredentialIssuer.Startup/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Authorization": {
33
"ClientId": "CredentialIssuer",
44
"ClientSecret": "password",
5-
"Issuer": "https://a766-81-246-134-116.ngrok-free.app/master",
5+
"Issuer": "https://e353-81-246-134-116.ngrok-free.app/master",
66
"IgnoreCertificateError": true
77
},
88
"PublicDid": "did:key:zBhBLmYmyihtomRdJJNEKzbPj51o4a3GYFeZoRHSABKUwqdjiQPY2dh5bhPNPoUW8q8EimVSbFMYZca45j58sJ6KCVgQr4m6JfTejcB2GAN33T5TzWRCmq5vg6NUYvhFD92JhKqUSEa8o12hW92UYbKHRfMfiBQY9QuXoff28U8eJskViACfc5i"

src/CredentialIssuer/SimpleIdServer.CredentialIssuer.Website.Startup/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"forceHttps": false,
1010
"CredentialIssuerUrl": "https://localhost:5005",
1111
"DefaultSecurityOptions": {
12-
"Issuer": "https://a766-81-246-134-116.ngrok-free.app/master",
12+
"Issuer": "https://e353-81-246-134-116.ngrok-free.app/master",
1313
"ClientId": "CredentialIssuer-manager",
1414
"ClientSecret": "password",
1515
"Scope": "openid profile",

src/CredentialIssuer/SimpleIdServer.CredentialIssuer.Website/Pages/Overview.razor

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
<RadzenTextBox Value=@GetCredentialIssuerUrl() Class="w-100"></RadzenTextBox>
1313
</div>
1414
</div>
15-
<div class="row">
16-
<div class="col-2">
17-
<RadzenLabel Text="@Global.CredentialIssuerDid" Style="padding: 0px;" />
18-
</div>
19-
</div>
2015
</RadzenCard>
2116

2217
@code {

src/CredentialIssuer/SimpleIdServer.CredentialIssuer/Api/Credential/CredentialController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public CredentialController(
5757
[HttpPost]
5858
public async Task<IActionResult> Get([FromBody] CredentialRequest request, CancellationToken cancellationToken)
5959
{
60+
// User subject must always be a DID.
6061
var scope = User.Claims.SingleOrDefault(c => c.Type == "scope")?.Value;
6162
var authorizedScopes = new List<string>();
6263
if (!string.IsNullOrWhiteSpace(scope))
@@ -77,7 +78,6 @@ private async Task<object> BuildDeferredCredential(
7778
CredentialValidationResult validationResult,
7879
CancellationToken cancellationToken)
7980
{
80-
var userDid = User.FindFirst(ClaimTypes.NameIdentifier).Value;
8181
var deferredCredential = new Domains.DeferredCredential
8282
{
8383
Status = Domains.DeferredCredentialStatus.PENDING,
@@ -89,7 +89,8 @@ private async Task<object> BuildDeferredCredential(
8989
EncryptionJwk = request.CredentialResponseEncryption == null ? null : JsonWebKeySerializer.Write(request.CredentialResponseEncryption?.Jwk),
9090
EncryptionAlg = request.CredentialResponseEncryption?.Alg,
9191
EncryptionEnc = request.CredentialResponseEncryption?.Enc,
92-
UserDid = userDid
92+
UserDid = validationResult.Subject,
93+
CreateDateTime = DateTime.UtcNow
9394
};
9495
_deferredCredentialStore.Add(deferredCredential);
9596
await _deferredCredentialStore.SaveChanges(cancellationToken);
@@ -114,18 +115,17 @@ private async Task<CredentialResult> BuildImmediateCredential(CredentialRequest
114115
CredentialValidationResult validationResult,
115116
CancellationToken cancellationToken)
116117
{
117-
var userDid = User.FindFirst(ClaimTypes.NameIdentifier).Value;
118118
Dictionary<string, string> claims = null;
119119
if (validationResult.Credential != null)
120120
claims = validationResult.Credential.Claims.ToDictionary(c => c.Name, c => c.Value);
121121
else
122122
{
123-
var userClaims = await _userCredentialClaimStore.Resolve(userDid, validationResult.CredentialConfiguration.Claims, cancellationToken);
123+
var userClaims = await _userCredentialClaimStore.Resolve(validationResult.Subject, validationResult.CredentialConfiguration.Claims, cancellationToken);
124124
claims = userClaims.ToDictionary(c => c.Name, c => c.Value);
125125
}
126126

127127
return _credentialService.BuildImmediateCredential(new BuildImmediateCredentialRequest(
128-
userDid,
128+
validationResult.Subject,
129129
validationResult.CredentialConfiguration,
130130
validationResult.Credential,
131131
claims,

src/IdServer/SimpleIdServer.IdServer.Domains/Token.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Token
77
{
88
public string Id { get; set; } = null!;
99
public string? SessionId { get; set; } = null;
10-
public string ClientId { get; set; } = null!;
10+
public string? ClientId { get; set; } = null!;
1111
public string TokenType { get; set; } = null!;
1212
public AccessTokenTypes? AccessTokenType { get; set; } = null;
1313
public string? Data { get; set; } = null;

src/IdServer/SimpleIdServer.IdServer.Startup/IdServerConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public class IdServerConfiguration
116116
ClientBuilder.BuildWalletClient("walletClient", "password")
117117
.SetClientName("Wallet")
118118
.Build(),
119-
ClientBuilder.BuildCredentialIssuer("CredentialIssuer", "password", null, "https://e1e9-81-246-134-116.ngrok-free.app/signin-oidc", "https://localhost:5005/*", "http://localhost:5005/*", "https://credentialissuer.simpleidserver.com/*", "https://credentialissuer.localhost.com/*", "https://credentialissuer.sid.svc.cluster.local/*")
119+
ClientBuilder.BuildCredentialIssuer("CredentialIssuer", "password", null, "https://8028-81-246-134-116.ngrok-free.app/signin-oidc", "https://localhost:5005/*", "http://localhost:5005/*", "https://credentialissuer.simpleidserver.com/*", "https://credentialissuer.localhost.com/*", "https://credentialissuer.sid.svc.cluster.local/*")
120120
.SetClientName("Credential issuer")
121121
.AddScope(
122122
SimpleIdServer.IdServer.Constants.StandardScopes.OpenIdScope,

src/IdServer/SimpleIdServer.IdServer/Api/Token/Handlers/PreAuthorizedCodeHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ public override async Task<IActionResult> Handle(HandlerContext context, Cancell
8383

8484
context.SetClient(oauthClient);
8585
var preAuthCode = await _validator.Validate(context, cancellationToken);
86-
if (!isClientExists)
87-
oauthClient.ClientId = preAuthCode.ClientId;
8886
activity?.SetTag("client_id", oauthClient.Id);
8987
await _dpopProofValidator.Validate(context);
9088
var scopes = preAuthCode.Scopes;

0 commit comments

Comments
 (0)