Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions handwritten/storage/src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3236,6 +3236,7 @@ class File extends ServiceObject<File, FileMetadata> {
contentMd5: cfg.contentMd5,
contentType: cfg.contentType,
host: cfg.host,
signingEndpoint: cfg.signingEndpoint,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When URLSigner receives this parameter, it passes it to auth.sign() as a second argument. The issue is that the public AuthClient interface only defines one parameter (sign(blobToSign: string)).

If a developer provides a custom AuthClient implementation based on our interface, Javascript will silently drop this new signingEndpoint argument at runtime. The user will receive a signed URL generated from the default endpoint, and they'll have no idea their custom config was ignored.

Suggestion: Could we update the AuthClient interface in src/signer.ts to explicitly include the optional parameter? sign(blobToSign: string, signingEndpoint?: string): Promise;

This will ensure custom implementers are aware they need to support it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've updated the AuthClient interface in src/signer.ts, it is now ​sign(blobToSign: string, signingEndpoint?: string): Promise<string>;

};

if (cfg.cname) {
Expand Down
2 changes: 1 addition & 1 deletion handwritten/storage/src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type GoogleAuthLike = Pick<GoogleAuth, 'getCredentials' | 'sign'>;
* @deprecated Use {@link GoogleAuth} instead
*/
export interface AuthClient {
sign(blobToSign: string): Promise<string>;
sign(blobToSign: string, signingEndpoint?: string): Promise<string>;
getCredentials(): Promise<{
client_email?: string;
}>;
Expand Down
19 changes: 19 additions & 0 deletions handwritten/storage/test/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3794,11 +3794,30 @@ describe('File', () => {
contentType: config.contentType,
cname: CNAME,
virtualHostedStyle: true,
signingEndpoint: undefined,
});
done();
});
});

it('should pass signingEndpoint to URLSigner', done => {
const signingEndpoint = 'https://my-endpoint.com';
const config = {
...SIGNED_URL_CONFIG,
signingEndpoint,
};
Comment thread
thiyaguk09 marked this conversation as resolved.

file.getSignedUrl(config, (err: Error | null) => {
assert.ifError(err);
const getSignedUrlArgs = signerGetSignedUrlStub.getCall(0).args;
assert.strictEqual(
getSignedUrlArgs[0]['signingEndpoint'],
signingEndpoint
);
done();
});
});

it('should add "x-goog-resumable: start" header if action is resumable', done => {
SIGNED_URL_CONFIG.action = 'resumable';
SIGNED_URL_CONFIG.extensionHeaders = {
Expand Down
Loading