Closed kevinbrewster closed 5 years ago
Since Basic Authentication requires a username and password, I don’t get the benefit of allowing the models to not supply it?
Let's say you have an online store and with a Customer model. Customers can optionally create a username/password but it's not required.
When someone logs in with Basic Authentication, I want to be able to search through the Customers to find a match with the same username/password even though not all customers have credentials (i.e. Basic Authentication skips over or ignores customers with a nil username or password).
@kevinbrewster an alternative way to model that would be to create a CustomerCredentials
entity that is a child of a Customer
. The credentials type would have non-optional values, yet it would still be optional on the customer because it may or may not have that child.
Given this is a somewhat unique situation, I think it could be preferable to handle it that way rather than make the base case more complex.
Closing due to inactivity - feel free to reopen!
Consider the scenario where not all users have username/passwords and thus those properties are optional.
Currently it's not possible to conform the below model to the BasicAuthenticable protocol because you need to supply WritableKeyPath<User, String> keys, not WritableKeyPath<User, String?>.
What do you think about allowing username /password fields of type WritableKeyPath<User, String?> to also conform to BasicAuthenticable?
I think this can be pulled off like so: