Skip to content

Add Authentication providers to JSON schema for autocomplete and validation #2643

Open
@sander1095

Description

@sander1095

At the time of writing, the JSON schema does not provide a list of possible authentication providers:

"authentication": {
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
"provider": {
"type": "string",
"description": "The name of authentication provider",
"default": "StaticWebApps"
},
"jwt": {
"type": "object",
"additionalProperties": false,
"properties": {
"audience": {
"type": "string"
},
"issuer": {
"type": "string"
}
}
}
}
}
}
},

  • This means that the user needs to read the documentation (or the source code) to find out all possible values, which is a bad developer experience
  • This means that there is no validation for the auth provider name until dab start is called, which badly affects the inner development loop.
  • This means there is also no validation of the auth provider name + jwt object combination for OAuth providers, like Custom.
    • It would be great for a user to get an error in their editor when they use the Custom auth provider but haven't provided the required jwt object.

These issues all have unit tests and are validated at dab start. Adding these cases to the JSON Schema will make it easier for developers to understand the authentication options, reduce time needed to fix issues as validation will take place in the editor as well, and make it easier to use Custom validation as the required jwt option would be pointed out by the schema.

This change doesn't seem like it would be to difficult to implement. As far as I know:

  • We need to add a list of auth providers to the JSON schema
  • We need to add conditional logic to the JSON schema that errors out when devs forget to add jwt when Custom is used, and also errors out when it is used for non-Custom auth options as this isn't valid.
  • We need to add a test that checks that the use of the jwt object with non-Custom auth providers throws an error.

I'd love to work on this in a while, when I'm done with moving houses and have some more headspace! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions