question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement a generic `authentication` api for web-client

See original GitHub issue

Currently 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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hectorventcommented, Oct 8, 2020

PR is done. Then I will be working on the Digest implementation.

1reaction
pmlopescommented, Oct 4, 2020

It exists, it comes from the auth-common module. io.vertx.ext.auth.User

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consume Web API Using WebClient In C# - C# Corner
In this blog, we will learn how to consume a Web API using a web client in C#.
Read more >
Basic Authentication in ASP.NET Web API - Microsoft Learn
A client authenticates itself by setting the Authorization header in the request. Browser clients perform this step automatically.
Read more >
Web Client - OneWelcome Identity Cloud for Developers
All endpoints are protected with API client using either Client Secret Basic or PrivateKeyJWT authentication method. It requires an API client with the...
Read more >
OAuth 2.0 for Client-side Web Applications | Authorization
This document explains how to implement OAuth 2.0 authorization to access Google APIs from a JavaScript web application.
Read more >
Custom Authorization Header with WebClient - Andrew Flower
Custom Auth Header for WebClient · Outline · Simple GET Request Signing · POST Data Signing - The General Approach · Summary.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found