Package that reads account data from appsettings.json and automatically performs login for convenient local development.
- When the Dev.Local section is configured in appsettings.json, the authentication will be enabled.
- Read the Claim data from the
Dev.Local
section ofappsettings.json
and set it into the ClaimsIdentity.
You can install the Dev Local Authentication library via NuGet Package Manager Console:
NuGet\Install-Package DevLocalAuthentication
Here's how you can use the library to auto login:
"Dev.Local": {
"Claims": {
"sub": "bbf6ea7e-c072-4e74-b359-4c51b8eb5442",
"NameIdentifier": "bbf6ea7e-c072-4e74-b359-4c51b8eb5442",
"Name": "x1@gss.com.tw",
"preferred_username": "x1@gss.com.tw",
"Email": "x1@gss.com.tw"
},
"Enable":"true"
// ,
//"AuthenticationType": "Dev.Local"
//"AuthenticationType": "Identity.Application"
//"AuthenticationType": "whateveryouwant"
}
// before app.UseAuthorization();
app.UseDevLocalAuthentication();
- [breaking] Change appsettings.json
Dev.Local
section - Use
app.UseDevLocalAuthentication()
instead ofcontext.Services.AddDevLocalAuthentication();
Use a instead of b
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.