Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API key to gRPC server and client #394

Merged
merged 3 commits into from
May 30, 2024
Merged

Conversation

plameniv
Copy link
Collaborator

No description provided.

@plameniv plameniv added enhancement New feature or request M-grpc This issue is related to the gRPC module labels May 29, 2024
@@ -86,7 +88,7 @@ export function createGrpcClient<T>(

const metaCallback = (_params: any, callback: (arg0: null, arg1: Metadata) => void) => {
const meta = new Metadata();
meta.add("custom-auth-header", "token");
meta.add("custom-auth-header", apiKey || DEFAULT_API_KEY);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can skip adding the header if there is no API Key provided. Also header name should be "authorization"

Suggested change
meta.add("custom-auth-header", apiKey || DEFAULT_API_KEY);
if(apiKey) {
meta.add("authorization", apiKey);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the if check a bit earlier

Comment on lines 79 to 80
certPath?: string,
apiKey?: string
Copy link
Contributor

Choose a reason for hiding this comment

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

May be we can turn this into object while this version is still in beta.
option?: {

Suggested change
certPath?: string,
apiKey?: string
options?: { certPath?: string,
apiKey?: string
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created a separate interfaces for server and client

Copy link
Collaborator

@cross311 cross311 left a comment

Choose a reason for hiding this comment

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

Either update version to be a breaking change version or just allow support for old and new way.

packages/grpc/src/index.ts Outdated Show resolved Hide resolved
@plameniv plameniv merged commit 9e54d65 into develop May 30, 2024
11 checks passed
@plameniv plameniv deleted the chore/add-api-key-to-grpc branch May 30, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request M-grpc This issue is related to the gRPC module
Development

Successfully merging this pull request may close these issues.

4 participants