To better context see Rich Authorization Requests for OAuth2
As u can read here there are some common data field types like actions
, locations
etc.
So I have created C# entity for EF as below:
public class AuthorizationDetails
{
public int Id { get; set; }
public string Type { get; set; }
public bool AlwaysRequireConsent { get; set; }
public ICollection<ApiResource> Locations { get; set; }
public string SpaceDelimitedActions { get; set; }
public string SpaceDelimitedDataTypes { get; set; }
public string SpaceDelimitedPrivileges { get; set; }
public ICollection<AuthorizationDetailsCustomDataField> CustomDataFields { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public ICollection<Client> Clients { get; set; }
}
There is no problem with these common fields. But I have to handle custom JSON data fields and register them. So I have created class called AuthorizationDetailsCustomDataField
which is related with one-to-many with AuthorizationDetails
entity.
It looks as below:
public class AuthorizationDetailsCustomDataField
{
public int Id { get; set; }
public string Name { get; set; }
public bool Required { get; set; }
}
So in JSON, the custom field with Name
="custom_field" can looks like it:
{
"custom_field":[
"read",
"write"
]
}
But it also can looks like it:
{
"custom_field":{
"x":1024,
"y":2048,
"z":{
"a":"3096",
"b":[
"abc",
"xyz"
]
}
}
}
How it looks depends on configuration. But how can I allow any configuration that developer wants? How can I design the database to make possible for developer to specify their own allowed JSON structures?
{"customField":["string"]}
or{"customField":{"x":"int","y":"int","z":{"a":"string", "b":["string"]}