Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Build the claimChallenge JSon string using C# anonymous types for better readbility/maintenability #3

@jmprieur

Description

@jmprieur

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ x ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

This line is hard to read, and write/modify and the compiler cannot verify if the JSon is well formed.

Expected/desired behavior

Proposing to change

tring claimsChallenge = "{\"id_token\":{\"acrs\":{\"essential\":true,\"value\":\"" + savedAuthContextId + "\"}}}";

into the following block, which uses C# anonymous types:

// Ask to have the optional claim named `acrs` in the ID Token.
// This claim will be essential, and its value will be `savedAuthContextId`
var claimsChallengeObjet = new
{
  id_token = new
  {
    acrs = new
    { 
      essential = true,
      value = savedAuthContextId
    }
  }
};
string claimsChallenge = JsonSerializer.Serialize(claimsChallengeObjet);

The same change would apply to the README.md file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions