dotnet / dotnet/aspnetcore

user-jwts does not support different Name and NameIdentifier claim

Open
#51,546 9 comments 2 reactions 0 assignees View on GitHub
area-commandlinetools External feature-userjwts Needs: Attention :wave:
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

basically what I want is to set `name` and `nameIdentifier` to different values, this is what I am trying to accomplish.

I am using user-jwts and here is my command

`dotnet user-jwts create --claim "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier=hakan@example.com" --claim "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name=hakan"`

I am not providing the `--name`, I know, but I tried that, and did not achieve what I wanted either.

what I am getting basically from the above command is duplicated claims, I am getting the `name` claim twice, and the `name identifier` twice,
The first pair of `name` and `nameidentifier` claims are set to the default windows user (this is expected by the documentation as I am not specifying anything to the --name option)
the second pair of `name` and `nameidentifier` claims are set to the second claim I specify in the above command `hakan`.

What I am trying to do is just set those 2 claims to different values (without duplicating them).
Is this a bug? or is this by design?

I tried to work around this by using IClaimsTransformation interface, but it only allow to add new claims not to modify or deleted the duplicated claims.

if this is confirmed a bug, maybe I can help with it

Thank you

### Expected Behavior

`name` and `nameidentifier` claims should be allowed to set to different values

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

7.0.401

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.