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

[Storage] Drop RawTokenCredential from storage packages #4788

Merged
merged 10 commits into from
Sep 6, 2019
8 changes: 2 additions & 6 deletions sdk/storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,8 @@ async function main() {
// SharedKeyCredential is only avaiable in Node.js runtime, not in browsers
const sharedKeyCredential = new SharedKeyCredential(account, accountKey);

// Use RawTokenCredential with OAuth token. You can find more
Copy link
Member

@XiaoningLiu XiaoningLiu Aug 19, 2019

Choose a reason for hiding this comment

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

We should leave a sample here for customers who want OAuth authentication.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe linking to the @azure/identity npmjs page. There's some documentation there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

// TokenCredential implementations in the @azure/identity library
// to use client secrets, certificates, or managed identities for
// authentication.
const tokenCredential = new RawTokenCredential("token");
tokenCredential.token = "renewedToken"; // Renew the token by updating token field of token credential
// You can find more TokenCredential implementations in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library
// to use client secrets, certificates, or managed identities for authentication.

// Use AnonymousCredential when url already includes a SAS signature
const anonymousCredential = new AnonymousCredential();
Expand Down
4 changes: 4 additions & 0 deletions sdk/storage/storage-blob/BreakingChanges.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Breaking Changes

### Coming soon... Version 12.0.0-preview.3

- `RawTokenCredential` is dropped. TokenCredential implementations can be found in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library for authentication.

### 2019.08 Version 12.0.0-preview.2

- [Breaking] Aborter class is no longer exposed from the package. Use the package [@azure/abort-controller](https://www.npmjs.com/package/@azure/abort-controller) to pass an abort signal to any of the async operations.
Expand Down
4 changes: 3 additions & 1 deletion sdk/storage/storage-blob/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

### 2019.08 Version 12.0.0-preview.3
### 2019.09 Version 12.0.0-preview.3

- [Breaking] `RawTokenCredential` is dropped. TokenCredential implementations can be found in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library for authentication.

- Pass through `options.abortSignal` to the optional `abortSignal` attribute in option bags instead of using `AbortSignal.none` as the default value when `options.abortSignal` is not specified.

Expand Down
5 changes: 2 additions & 3 deletions sdk/storage/storage-blob/samples/javascript/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ async function main() {
// will be used as a fallback authentication source.
// const defaultAzureCredential = new DefaultAzureCredential();

// Use TokenCredential with OAuth token
// const tokenCredential = new RawTokenCredential("token");
// tokenCredential.token = "renewedToken"; // Renew the token by updating token field of token credential
// You can find more TokenCredential implementations in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library
// to use client secrets, certificates, or managed identities for authentication.

// Use AnonymousCredential when url already includes a SAS signature
// const anonymousCredential = new AnonymousCredential();
Expand Down
5 changes: 2 additions & 3 deletions sdk/storage/storage-blob/samples/typescript/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ async function main() {
// will be used as a fallback authentication source.
// const defaultAzureCredential = new DefaultAzureCredential();

// Use TokenCredential with OAuth token
// const tokenCredential = new RawTokenCredential("token");
// tokenCredential.token = "renewedToken"; // Renew the token by updating token field of token credential
// You can find more TokenCredential implementations in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library
// to use client secrets, certificates, or managed identities for authentication.

// Use AnonymousCredential when url already includes a SAS signature
// const anonymousCredential = new AnonymousCredential();
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/src/AppendBlobClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class AppendBlobClient extends BlobClient {
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* However, if a blob name includes ? or %, blob name must be encoded in the URL.
* Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/src/BlobClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ export class BlobClient extends StorageClient {
* @param {string} url A Client string pointing to Azure Storage blob service, such as
* "https://myaccount.blob.core.windows.net". You can append a SAS
* if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/src/BlobServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export class BlobServiceClient extends StorageClient {
* @param {string} url A Client string pointing to Azure Storage blob service, such as
* "https://myaccount.blob.core.windows.net". You can append a SAS
* if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/src/ContainerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class ContainerClient extends StorageClient {
* Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped.
* However, if a blob name includes ? or %, blob name must be encoded in the URL.
* Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/src/PageBlobClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class PageBlobClient extends BlobClient {
* @param {string} url A Client string pointing to Azure Storage blob service, such as
* "https://myaccount.blob.core.windows.net". You can append a SAS
* if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity.
* @param {NewPipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
* @memberof PageBlobClient
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/src/Pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface NewPipelineOptions {
* Creates a new Pipeline object with Credential provided.
*
* @export
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity.
* @param {NewPipelineOptions} [pipelineOptions] Optional. Options.
* @returns {Pipeline} A new Pipeline object.
Expand Down
59 changes: 0 additions & 59 deletions sdk/storage/storage-blob/src/credentials/RawTokenCredential.ts

This file was deleted.

1 change: 0 additions & 1 deletion sdk/storage/storage-blob/src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export * from "./PageBlobClient";
export * from "./BrowserPolicyFactory";
export * from "./credentials/AnonymousCredential";
export * from "./credentials/Credential";
export * from "./credentials/RawTokenCredential";
export { IPRange } from "./IPRange";
export { Range } from "./Range";
export * from "./LeaseClient";
Expand Down
1 change: 0 additions & 1 deletion sdk/storage/storage-blob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export * from "./ContainerSASPermissions";
export * from "./credentials/AnonymousCredential";
export * from "./credentials/Credential";
export * from "./credentials/SharedKeyCredential";
export * from "./credentials/RawTokenCredential";
export { IPRange } from "./IPRange";
export { Range } from "./Range";
export * from "./LeaseClient";
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/test/utils/index.browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SimpleTokenCredential } from "@azure/core-http";
import { AnonymousCredential } from "../../src/credentials/AnonymousCredential";
import { BlobServiceClient } from "../../src/BlobServiceClient";
import { newPipeline } from "../../src/Pipeline";
import { SimpleTokenCredential } from "./testutils.common";

export * from "./testutils.common";

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/test/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as dotenv from "dotenv";
import * as fs from "fs";
import * as path from "path";

import { SimpleTokenCredential } from "@azure/core-http";
import { SimpleTokenCredential } from "./testutils.common";
import { SharedKeyCredential } from "../../src/credentials/SharedKeyCredential";
import { BlobServiceClient } from "../../src/BlobServiceClient";
import { getUniqueName } from "./testutils.common";
Expand Down
46 changes: 46 additions & 0 deletions sdk/storage/storage-blob/test/utils/testutils.common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
import { HttpPipelineLogLevel, IHttpPipelineLogger } from "../../src/Pipeline";
import { padStart } from "../../src/utils/utils.common";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";

/**
* A TokenCredential that always returns the given token. This class can be
* used when the access token is already known or can be retrieved from an
* outside source.
*/
export class SimpleTokenCredential implements TokenCredential {
/**
* The raw token string. Can be changed when the token needs to be updated.
*/
public token: string;

/**
* The Date at which the token expires. Can be changed to update the expiration time.
*/
public expiresOn: Date;

/**
* Creates an instance of TokenCredential.
* @param {string} token
*/
constructor(token: string, expiresOn?: Date) {
this.token = token;
this.expiresOn = expiresOn ? expiresOn : new Date(Date.now() + 60 * 60 * 1000);
}

/**
* Retrieves the token stored in this RawTokenCredential.
*
* @param _scopes Ignored since token is already known.
* @param _options Ignored since token is already known.
* @returns {AccessToken} The access token details.
*/
async getToken(
_scopes: string | string[],
_options?: GetTokenOptions
): Promise<AccessToken | null> {
return {
token: this.token,
expiresOnTimestamp: this.expiresOn.getTime()
};
}
}

export function isBrowser(): boolean {
return typeof window !== "undefined";
Expand Down Expand Up @@ -41,3 +85,5 @@ export class ConsoleHttpPipelineLogger implements IHttpPipelineLogger {
}
}
}

export {};
4 changes: 4 additions & 0 deletions sdk/storage/storage-queue/BreakingChanges.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Breaking Changes

### Coming soon... Version 12.0.0-preview.3

- [Breaking] `RawTokenCredential` is dropped. TokenCredential implementations can be found in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library for authentication.

### 2019.08 Version 12.0.0-preview.2

- [Breaking] Aborter class is no longer exposed from the package. Use the package [@azure/abort-controller](https://www.npmjs.com/package/@azure/abort-controller) to pass an abort signal to any of the async operations.
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/storage-queue/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### 2019.08 Version 12.0.0-preview.3

- [Breaking] `RawTokenCredential` is dropped. TokenCredential implementations can be found in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library for authentication.

- Pass through `options.abortSignal` to the optional `abortSignal` attribute in option bags instead of using `AbortSignal.none` as the default value when `options.abortSignal` is not specified.

### 2019.08 Version 12.0.0-preview.2
Expand Down
8 changes: 2 additions & 6 deletions sdk/storage/storage-queue/samples/javascript/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ async function main() {
// will be used as a fallback authentication source.
// const defaultAzureCredential = new DefaultAzureCredential();

// Use RawTokenCredential with OAuth token. You can find more
// TokenCredential implementations in the @azure/identity library
// to use client secrets, certificates, or managed identities for
// authentication.
// const tokenCredential = new RawTokenCredential("token");
// tokenCredential.token = "renewedToken"; // Renew the token by updating token field of token credential
// You can find more TokenCredential implementations in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library
// to use client secrets, certificates, or managed identities for authentication.

// Use AnonymousCredential when url already includes a SAS signature
// const anonymousCredential = new AnonymousCredential();
Expand Down
8 changes: 2 additions & 6 deletions sdk/storage/storage-queue/samples/typescript/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ async function main() {
// Only available in Node.js runtime
// const defaultAzureCredential = new DefaultAzureCredential();

// Use RawTokenCredential with OAuth token. You can find more
// TokenCredential implementations in the @azure/identity library
// to use client secrets, certificates, or managed identities for
// authentication.
// const tokenCredential = new RawTokenCredential("token");
// tokenCredential.token = "renewedToken"; // Renew the token by updating token field of token credential
// You can find more TokenCredential implementations in the [@azure/identity](https://www.npmjs.com/package/@azure/identity) library
// to use client secrets, certificates, or managed identities for authentication.

// Use AnonymousCredential when url already includes a SAS signature
// const anonymousCredential = new AnonymousCredential();
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-queue/src/MessageIdClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class MessageIdClient extends StorageClient {
* "https://myaccount.queue.core.windows.net/myqueue/messages/messageid". You can
* append a SAS if using AnonymousCredential, such as
* "https://myaccount.queue.core.windows.net/myqueue/messages/messageid?sasString".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [options] Options to configure the HTTP pipeline.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-queue/src/MessagesClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class MessagesClient extends StorageClient {
* "https://myaccount.queue.core.windows.net/myqueue/messages". You can
* append a SAS if using AnonymousCredential, such as
* "https://myaccount.queue.core.windows.net/myqueue/messages?sasString".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [options] Options to configure the HTTP pipeline.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-queue/src/Pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface NewPipelineOptions {
* Creates a new Pipeline object with Credential provided.
*
* @static
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [pipelineOptions] Options.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-queue/src/QueueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class QueueClient extends StorageClient {
* "https://myaccount.queue.core.windows.net/myqueue". You can
* append a SAS if using AnonymousCredential, such as
* "https://myaccount.queue.core.windows.net/myqueue?sasString".
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential, RawTokenCredential,
* @param {SharedKeyCredential | AnonymousCredential | TokenCredential} credential Such as AnonymousCredential, SharedKeyCredential
* or a TokenCredential from @azure/identity. If not specified,
* AnonymousCredential is used.
* @param {NewPipelineOptions} [options] Options to configure the HTTP pipeline.
Expand Down
Loading