Implement a generic `authentication` api for web-client
See original GitHub issueCurrently web-client
only supports out of the box authentication for Basic
and Bearer
tokens. The API is designed with specific method calls for each method. We could improve this by designing a new API that would be generic and would allow future additions without breaking the API.
In web-client HttpRequest
interface we should add 2 new methods:
default HttpRequest<T> authentication(AuthenticationType type, User user) {
return authentication(type, user, null);
}
HttpRequest<T> authentication(AuthenticationType, User user, JsonObject options);
The AuthenticationType
should be an enum that respects the IANA
registry https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml , for example:
enum AuthenticationType {
BASIC,
DIGEST,
BEARER
}
The implementation can initially use a switch statement for the enum type:
switch (type) {
case BASIC:
// get the username + password from `user`, concat and base64 it
break;
case BEARER:
// get the access_token from `user`
break;
case DIGEST:
// compute the digest using the extra options
break;
...
The implementation shall be trivial for BASIC
and BEARER
as it should do exactly what the existing code code.
Finally deprecate the old APIs and at the interface level, call the new API using default methods.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
PR is done. Then I will be working on the Digest implementation.
It exists, it comes from the auth-common module.
io.vertx.ext.auth.User