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 type definition for AthenzX509Config #358

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class AuthenticationTls {
}

export class AuthenticationAthenz {
constructor(params: string | AthenzConfig);
constructor(params: string | AthenzConfig | AthenzX509Config);
}

export interface AthenzConfig {
Expand All @@ -198,9 +198,22 @@ export interface AthenzConfig {
keyId?: string;
principalHeader?: string;
roleHeader?: string;
caCert?: string;
/**
* @deprecated
*/
tokenExpirationTime?: string;
}

export class AthenzX509Config {
providerDomain: string;
privateKey: string;
x509CertChain: string;
ztsUrl: string;
roleHeader?: string;
caCert?: string;
}

export class AuthenticationToken {
constructor(params: { token: string });
}
Expand Down
10 changes: 10 additions & 0 deletions tstest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ import Pulsar = require('./index');
principalHeader: 'Athenz-Principal-Auth',
roleHeader: 'Athenz-Role-Auth',
tokenExpirationTime: '3600',
caCert: 'file:///path/to/cacert.pem',
});

const authAthenz3: Pulsar.AuthenticationAthenz = new Pulsar.AuthenticationAthenz({
providerDomain: 'athenz.provider.domain',
privateKey: 'file:///path/to/private.key',
ztsUrl: 'https://localhost:8443',
roleHeader: 'Athenz-Role-Auth',
x509CertChain: 'file:///path/to/x509cert.pem',
caCert: 'file:///path/to/cacert.pem',
});

const authOauth2PrivateKey: Pulsar.AuthenticationOauth2 = new Pulsar.AuthenticationOauth2({
Expand Down