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.

Add support for Authentication

See original GitHub issue

Allow to configure authentication method for the Kafka Connect cluster. I’ve done a quick test (clumpsy, I know) and works adding the ClientHeaderParam anotation at interface level. The values should be obtained from the configuration, obviously.

I’m not an expert in this REST Client library, and probably there is a better way to implement this solution.

Also, this is only covering BasicAuth and other authentication methods could be included as well.

If this is out of scope, don’t hesitate to close this one 😉

/*
 *  Copyright 2021 The original authors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package dev.morling.kccli.service;

import java.util.Base64;
import java.util.List;
import java.util.Map;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import org.eclipse.microprofile.rest.client.annotation.ClientHeaderParam;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@Path("/")
@RegisterRestClient
@ClientHeaderParam(name = "Authorization", value = "{getBasicAuth}")
public interface KafkaConnectApi {

    @GET
    KafkaConnectInfo getWorkerInfo();

    @GET
    @Path("/connector-plugins")
    List<ConnectorPlugin> getConnectorPlugins();

    @GET
    @Path("/connectors/")
    List<String> getConnectors();

    @POST
    @Path("/connectors/")
    ConnectorStatusInfo createConnector(String config);

    @GET
    @Path("/connectors/{name}")
    ConnectorInfo getConnector(@PathParam("name") String name);

    @POST
    @Path("/connectors/{name}/restart")
    void restartConnector(@PathParam("name") String name);

    @DELETE
    @Path("/connectors/{name}")
    void deleteConnector(@PathParam("name") String name);

    @GET
    @Path("/connectors/{name}/status")
    ConnectorStatusInfo getConnectorStatus(@PathParam("name") String name);

    @GET
    @Path("/connectors/{name}/topics")
    Map<String, TopicsInfo> getConnectorTopics(@PathParam("name") String name);

    @GET
    @Path("/connectors/{name}/config")
    Map<String, String> getConnectorConfig(@PathParam("name") String name);

    @PUT
    @Path("/connectors/{name}/config")
    ConnectorStatusInfo updateConnector(@PathParam("name") String name, String config);

    @POST
    @Path("/connectors/{name}/tasks/{id}/restart")
    ConnectorInfo restartTask(@PathParam("name") String name, @PathParam("id") String id);

    default String getBasicAuth() {
        return "Basic " +
                Base64.getEncoder().encodeToString("username:password".getBytes());
    }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tonyfosterdevcommented, Oct 8, 2021

@jmcristobal I believe you should be all set now. This PR is merged.

0reactions
gunnarmorlingcommented, Oct 9, 2021

Indeed, thanks again. Will close this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overview of ASP.NET Core Authentication - Microsoft Learn
The Authentication middleware is added in Program.cs by calling UseAuthentication. Calling UseAuthentication registers the middleware that uses ...
Read more >
How to Fix Support for password authentication was removed ...
Step 1: Create Access Token on GitHub · Click on your GitHub profile icon on the top right corner · Click Settings ·...
Read more >
The 'support for password authentication removed' GitHub error
Steps to fix GitHub's 'support for password authentication was removed' error · Log into GitHub with your username and password · Navigate to...
Read more >
Authentication - Swagger
API keys can now be sent in: cookie . Added support for OpenID Connect Discovery ( type: openIdConnect ). OAuth 2 security schemes...
Read more >
HTTP authentication - MDN Web Docs - Mozilla
A client that wants to authenticate itself with the server can then do so by including an Authorization request header with the credentials....
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