Skip to content

Commit b565bad

Browse files
committed
docs: Add warning note about user provided credential configurations.
Towards b/389125232
1 parent 83b2ac0 commit b565bad

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

Src/Support/Google.Apis.Auth/OAuth2/GoogleCredential.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
*/
1616

1717
using Google.Apis.Http;
18-
using Google.Apis.Util;
1918
using System;
2019
using System.Collections.Generic;
2120
using System.IO;
@@ -114,6 +113,13 @@ public static Task<GoogleCredential> GetApplicationDefaultAsync(CancellationToke
114113
/// Console or a stored user credential using the format supported by the Cloud SDK.
115114
/// </para>
116115
/// </summary>
116+
/// <remarks>
117+
/// Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source
118+
/// for authentication to Google Cloud, you must validate it before providing it to any Google API or library.
119+
/// Providing an unvalidated credential configuration to Google APIs can compromise the security of your
120+
/// systems and data. For more information, refer to
121+
/// <see href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">Validate credential configurations from external sources</see>.
122+
/// </remarks>
117123
public static GoogleCredential FromStream(Stream stream) => defaultCredentialProvider.CreateDefaultCredentialFromStream(stream);
118124

119125
/// <summary>
@@ -123,6 +129,13 @@ public static Task<GoogleCredential> GetApplicationDefaultAsync(CancellationToke
123129
/// Console or a stored user credential using the format supported by the Cloud SDK.
124130
/// </para>
125131
/// </summary>
132+
/// <remarks>
133+
/// Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source
134+
/// for authentication to Google Cloud, you must validate it before providing it to any Google API or library.
135+
/// Providing an unvalidated credential configuration to Google APIs can compromise the security of your
136+
/// systems and data. For more information, refer to
137+
/// <see href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">Validate credential configurations from external sources</see>.
138+
/// </remarks>
126139
public static Task<GoogleCredential> FromStreamAsync(Stream stream, CancellationToken cancellationToken) =>
127140
defaultCredentialProvider.CreateDefaultCredentialFromStreamAsync(stream, cancellationToken);
128141

@@ -135,6 +148,13 @@ public static Task<GoogleCredential> FromStreamAsync(Stream stream, Cancellation
135148
/// </summary>
136149
/// <param name="path">The path to the credential file.</param>
137150
/// <returns>The loaded credentials.</returns>
151+
/// <remarks>
152+
/// Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source
153+
/// for authentication to Google Cloud, you must validate it before providing it to any Google API or library.
154+
/// Providing an unvalidated credential configuration to Google APIs can compromise the security of your
155+
/// systems and data. For more information, refer to
156+
/// <see href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">Validate credential configurations from external sources</see>.
157+
/// </remarks>
138158
public static GoogleCredential FromFile(string path)
139159
{
140160
using (var f = File.OpenRead(path))
@@ -153,6 +173,13 @@ public static GoogleCredential FromFile(string path)
153173
/// <param name="path">The path to the credential file.</param>
154174
/// <param name="cancellationToken">Cancellation token for the operation.</param>
155175
/// <returns>The loaded credentials.</returns>
176+
/// <remarks>
177+
/// Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source
178+
/// for authentication to Google Cloud, you must validate it before providing it to any Google API or library.
179+
/// Providing an unvalidated credential configuration to Google APIs can compromise the security of your
180+
/// systems and data. For more information, refer to
181+
/// <see href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">Validate credential configurations from external sources</see>.
182+
/// </remarks>
156183
public static async Task<GoogleCredential> FromFileAsync(string path, CancellationToken cancellationToken)
157184
{
158185
using (var f = File.OpenRead(path))
@@ -168,13 +195,27 @@ public static async Task<GoogleCredential> FromFileAsync(string path, Cancellati
168195
/// Console or a stored user credential using the format supported by the Cloud SDK.
169196
/// </para>
170197
/// </summary>
198+
/// <remarks>
199+
/// Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source
200+
/// for authentication to Google Cloud, you must validate it before providing it to any Google API or library.
201+
/// Providing an unvalidated credential configuration to Google APIs can compromise the security of your
202+
/// systems and data. For more information, refer to
203+
/// <see href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">Validate credential configurations from external sources</see>.
204+
/// </remarks>
171205
public static GoogleCredential FromJson(string json) => defaultCredentialProvider.CreateDefaultCredentialFromJson(json);
172206

173207
/// <summary>
174208
/// Loads a credential from JSON credential parameters. Fields are a union of credential fields
175209
/// for all supported types. <see cref="JsonCredentialParameters"/> for more detailed information
176210
/// about supported types and corresponding fields.
177211
/// </summary>
212+
/// <remarks>
213+
/// Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source
214+
/// for authentication to Google Cloud, you must validate it before providing it to any Google API or library.
215+
/// Providing an unvalidated credential configuration to Google APIs can compromise the security of your
216+
/// systems and data. For more information, refer to
217+
/// <see href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">Validate credential configurations from external sources</see>.
218+
/// </remarks>
178219
public static GoogleCredential FromJsonParameters(JsonCredentialParameters credentialParameters) =>
179220
defaultCredentialProvider.CreateDefaultCredentialFromParameters(credentialParameters);
180221

Src/Support/Google.Apis.Auth/OAuth2/ServiceAccountCredential.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ public ServiceAccountCredential(Initializer initializer) : base(initializer)
194194
/// The <paramref name="credentialData"/> does not contain valid JSON service account key data.
195195
/// </exception>
196196
/// <returns>The credentials parsed from the service account key data.</returns>
197+
/// <remarks>
198+
/// Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source
199+
/// for authentication to Google Cloud, you must validate it before providing it to any Google API or library.
200+
/// Providing an unvalidated credential configuration to Google APIs can compromise the security of your
201+
/// systems and data. For more information, refer to
202+
/// <see href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">Validate credential configurations from external sources</see>.
203+
/// </remarks>
197204
public static ServiceAccountCredential FromServiceAccountData(Stream credentialData)
198205
{
199206
var credential = GoogleCredential.FromStream(credentialData);

0 commit comments

Comments
 (0)