Skip to content

Calling dotnet user-jwts while app is running causes malformed appsettings #44869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #46263
captainsafia opened this issue Nov 3, 2022 · 6 comments
Closed
Tracked by #46263
Assignees
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-userjwts The `dotnet user-jwts` CLI tool

Comments

@captainsafia
Copy link
Member

No description provided.

@captainsafia captainsafia added the old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Nov 3, 2022
@captainsafia captainsafia added this to the .NET 8 Planning milestone Nov 15, 2022
@captainsafia captainsafia self-assigned this Nov 15, 2022
@ghost
Copy link

ghost commented Nov 15, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@DamianEdwards
Copy link
Member

I experienced a malformed appsettings.Development.json when using dotnet user-jwts yesterday and I definitely ran the tool while the file was open in Visual Studio, and very possibly while the app was running (but not sure). The resulting errors from dotnet user-jwts weren't great either, as the JWT manipulations operations would actually succeed, but I'd get an error in the console like:

'}' is invalid after a single JSON value. Expected end of data. Path: $ | LineNumber: 20 | BytePositionInLine: 1.

We should likely look at handling JSON exceptions in the tool and displaying a more user-friendly error message.

@glen-84
Copy link
Contributor

glen-84 commented Jan 24, 2023

This seems to be happening even if the app isn't running.

@mikeblakeuk
Copy link

I found just having my json formatted to 4 spaces instead of 2 kills it

  1. dotnet user-jwts create
  2. format based on EditorConfig to 4 spacess instead of 2
  3. dotnet user-jwts create
  4. view json
{
  "Authentication": {
    "Schemes": {
      "Bearer": {
        "ValidAudiences": [
          "https://localhost:44310"
        ],
        "ValidIssuer": "dotnet-user-jwts"
      }
    }
  }
}r": "dotnet-user-jwts"
            }
        }
    }
}

@ci-vamp
Copy link

ci-vamp commented Apr 16, 2023

not sure if its related but it keeps removing one of my valid audiences whenever i run the command to generate a token. please dont push this out to dotnet 8. its unusable in its current state

note: this happens whether:

  • API is running or stopped
  • appsettings has 2 or 4 space indents

notice it deletes the valid audience and then it mangles the file (you can see the red underline at the top) right after i create the token

2 space

removing-valid-audience.mov

4 space

in the case of 4 space it edits the file, sets it to 2 space then mangles

removing-valid-audience-4space.mov

@captainsafia captainsafia added area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-userjwts The `dotnet user-jwts` CLI tool and removed old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels May 22, 2023
@captainsafia
Copy link
Member Author

OK -- I was able to get a repro and a bug fix for the original issue around malformed settings being written when the user-jwts CLI tool is being called twice.

@ci-vamp @mikeblakeuk I'm not sure if the presence of the editor config is a red herring in your scenarios. In any case, do you mind filling a separate issue for that so we can investigate it independently? I'll ping you when the bug fix for this one is merged in case it resolves your issues as well.

@ghost ghost locked as resolved and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-userjwts The `dotnet user-jwts` CLI tool
Projects
No open projects
Status: No status
Development

No branches or pull requests

5 participants