Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions SecurityService.IntegrationTests/Users/Users.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions SecurityService/Oidc/OidcEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static async Task<IResult> TokenAsync(
{
return InvalidGrant("The token is no longer valid.");
}

var principal = await OidcHelpers.CreatePrincipalAsync(
user,
userManager,
Expand Down Expand Up @@ -175,8 +175,10 @@ await scopeManager.ListResourcesAsync(ImmutableArray.CreateRange(authenticationR
return InvalidGrant();
}

var resources = await scopeManager.ListResourcesAsync(ImmutableArray.CreateRange(request.GetScopes()), cancellationToken).ToListAsync(cancellationToken);
var principal = await OidcHelpers.CreatePrincipalAsync(user, userManager, request.GetScopes(), resources, authorizationId: null);
var grantedScopes = await ResolveClientCredentialsScopesAsync(request, dbContext, cancellationToken);

var resources = await scopeManager.ListResourcesAsync(ImmutableArray.CreateRange(grantedScopes), cancellationToken).ToListAsync(cancellationToken);
var principal = await OidcHelpers.CreatePrincipalAsync(user, userManager, grantedScopes, resources, authorizationId: null);
return Results.SignIn(principal, authenticationScheme: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
}

Expand Down
3 changes: 2 additions & 1 deletion SecurityService/Oidc/OidcHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public static async Task<ClaimsPrincipal> CreatePrincipalAsync(
identity.SetClaim(Claims.Subject, user.Id)
.SetClaim(Claims.Email, user.Email)
.SetClaim(Claims.Name, user.UserName)
.SetClaim(Claims.PreferredUsername, user.UserName);
.SetClaim(Claims.PreferredUsername, user.UserName)
.SetClaim(ClaimTypes.NameIdentifier, user.Id);

if (string.IsNullOrWhiteSpace(user.GivenName) == false)
{
Expand Down
5 changes: 1 addition & 4 deletions SecurityService/Services/GrantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using SecurityService.Models;
using SimpleResults;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using static OpenIddict.Abstractions.OpenIddictConstants;

namespace SecurityService.Services;
Expand Down Expand Up @@ -76,6 +75,4 @@ public async Task<Result> RevokeAsync(string userId, string authorizationId, Can
? Result.Success()
: Result.Failure("The authorization could not be revoked.");
}
}


}
12 changes: 1 addition & 11 deletions SecurityService/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
{
"ConnectionStrings": {
"AuthenticationDbContext": "Server=127.0.0.1;Database=NewSecurityService;user id=sa;password=sp1ttal;Encrypt=false"
"AuthenticationDbContext": "Server=127.0.0.1;Database=SecurityService;user id=sa;password=sp1ttal;Encrypt=false"
},
//"SecurityService": {
// "UseInMemoryDatabase": false,
// "InMemoryDatabaseName": "NewSecurityService",
// "DatabaseProvider": "SqlServer",
// "IssuerUrl": "https://localhost:5001/",
// "SeedDefaultScopes": true,
// "PublicOrigin": "https://localhost:5001/",
// "ExternalProviders": [],
// "SignInOptions"
//},
"ServiceOptions": {
"SeedDefaultScopes": false,
"PublicOrigin": "https://127.0.0.1:50001",
Expand Down
Loading