Skip to content

Conversation

bevzzz
Copy link
Collaborator

@bevzzz bevzzz commented Jun 13, 2025

API Key authorization

In this PR we introduce a TokenProvider interface, which is a popular abstraction for dealing with access tokens. io.weaviate.client6 exports Authorization util class with factory methods to setup (various kinds of, in the future) token providers.

For example, Authorization.apiKey("my-api-key") creates a TokenProvider for a static Weaviate API key.

Connection helpers

// Local Weaviate instance with default parameters:
// scheme=http, host=localhost, httpPort=8080, grpcPort=50051
var local = WeaviateClient.local();
var localAsync = WeaviateClientAsync.local();

// Weaviate Cloud instance with default parameters:
// scheme=https, httpPort=443, grpcPort=443
var wcd = WeaviateClient.wcd("my-cluster.wcd.com", "token-xyz");
var wcdAsync = WeaviateClientAsync.wcd("my-cluster.wcd.com", "token-xyz");

When connecting to a Weaviate Cloud instance, gRPC host is inferred: "grpc-" + httpHost, similarly to Python's client.

// Custom configuration
var custom = new WeaviateClient(Config.of(
  "https", cfg -> cfg
    .httpHost("my-http-host.com")
    .grpcHost("my-grpc-host.com")
    .authorization(Authorization.apiKey("token-123"))
    .setHeader("X-Custom-Header", "abc+def")
));

Extended Rest/GrpcTransport to use custom authorization interceptors, if tokenProvider != null.
Added Config.Builder for providing flexible options.
Added connection helpers: .local() and .wcd()
Copy link

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 1   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Failed Failed Vulnerabilities high 1   medium 0   low 0   info 0 View in Orca
🛡️ The following SAST misconfigurations have been detected
NAME FILE
medium Insecure Random Number Generator Usage in Java .../ConcurrentTest.java View in code
☢️ The following Vulnerabilities (CVEs) have been detected
PACKAGE FILE CVE ID INSTALLED VERSION FIXED VERSION
high org.apache.httpcomponents.client5:httpclient5 ./pom.xml CVE-2025-27820 5.4.2 5.4.3 View in code

@bevzzz bevzzz changed the base branch from main to v6 June 13, 2025 15:57
Copy link

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@bevzzz bevzzz self-assigned this Jun 13, 2025
@bevzzz bevzzz linked an issue Jun 13, 2025 that may be closed by this pull request
@bevzzz bevzzz marked this pull request as ready for review June 15, 2025 17:17
@bevzzz bevzzz force-pushed the feat/auth-and-helpers branch from 32edf7c to ffd7214 Compare June 16, 2025 10:54
@bevzzz bevzzz merged commit 41188ea into v6 Jun 16, 2025
2 checks passed
@bevzzz bevzzz deleted the feat/auth-and-helpers branch June 16, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Authentication and connection helpers
2 participants