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
9 changes: 8 additions & 1 deletion src/blob/BlobEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ export default class BlobEnvironment implements IBlobEnvironment {
}

public oauth(): string | undefined {
return this.flags.oauth;
if (this.flags.oauth !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add changelog, and better with test cases.

if (this.flags.oauth !== "basic") {
Copy link
Member

@blueww blueww May 22, 2025

Choose a reason for hiding this comment

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

Please don't hard code "basic".
The basic here means Azurite only do basic validation of the Bearer token. It give the scalability for adding more validation to the bearer token with more value for "--Oauth" in the future.
So please add an enum for the value support by Oauth, and report error when the value not in the enum.
It's better to have the validation code in a single function, instead of several copy of it.

throw RangeError(
`Must provide a valid value for parameter --oauth, only 'basic' is supported.`
);
}
return this.flags.oauth;
}
}

public disableProductStyleUrl(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/common/ConfigurationBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default abstract class ConfigurationBase {
}

public getOAuthLevel(): undefined | OAuthLevel {
if (this.oauth) {
if (this.oauth && typeof this.oauth === "string") {
if (this.oauth.toLowerCase() === "basic") {
return OAuthLevel.BASIC;
}
Expand Down
9 changes: 8 additions & 1 deletion src/common/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ export default class Environment implements IEnvironment {
}

public oauth(): string | undefined {
return this.flags.oauth;
if (this.flags.oauth !== undefined) {
if (this.flags.oauth !== "basic") {
throw RangeError(
`Must provide a valid value for parameter --oauth, only 'basic' is supported.`
);
}
return this.flags.oauth;
}
}

public inMemoryPersistence(): boolean {
Expand Down
9 changes: 8 additions & 1 deletion src/queue/QueueEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ export default class QueueEnvironment implements IQueueEnvironment {
}

public oauth(): string | undefined {
return this.flags.oauth;
if (this.flags.oauth !== undefined) {
if (this.flags.oauth !== "basic") {
throw RangeError(
`Must provide a valid value for parameter --oauth, only 'basic' is supported.`
);
}
return this.flags.oauth;
}
}

public disableProductStyleUrl(): boolean {
Expand Down
9 changes: 8 additions & 1 deletion src/table/TableEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ export default class TableEnvironment implements ITableEnvironment {
}

public oauth(): string | undefined {
return this.flags.oauth;
if (this.flags.oauth !== undefined) {
if (this.flags.oauth !== "basic") {
throw RangeError(
`Must provide a valid value for parameter --oauth, only 'basic' is supported.`
);
}
return this.flags.oauth;
}
}

public cert(): string | undefined {
Expand Down
Loading