auth.proto 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. // Copyright 2019 Google LLC.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. syntax = "proto3";
  16. package google.api;
  17. option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "AuthProto";
  20. option java_package = "com.google.api";
  21. option objc_class_prefix = "GAPI";
  22. // `Authentication` defines the authentication configuration for an API.
  23. //
  24. // Example for an API targeted for external use:
  25. //
  26. // name: calendar.googleapis.com
  27. // authentication:
  28. // providers:
  29. // - id: google_calendar_auth
  30. // jwks_uri: https://www.googleapis.com/oauth2/v1/certs
  31. // issuer: https://securetoken.google.com
  32. // rules:
  33. // - selector: "*"
  34. // requirements:
  35. // provider_id: google_calendar_auth
  36. message Authentication {
  37. // A list of authentication rules that apply to individual API methods.
  38. //
  39. // **NOTE:** All service configuration rules follow "last one wins" order.
  40. repeated AuthenticationRule rules = 3;
  41. // Defines a set of authentication providers that a service supports.
  42. repeated AuthProvider providers = 4;
  43. }
  44. // Authentication rules for the service.
  45. //
  46. // By default, if a method has any authentication requirements, every request
  47. // must include a valid credential matching one of the requirements.
  48. // It's an error to include more than one kind of credential in a single
  49. // request.
  50. //
  51. // If a method doesn't have any auth requirements, request credentials will be
  52. // ignored.
  53. message AuthenticationRule {
  54. // Selects the methods to which this rule applies.
  55. //
  56. // Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
  57. string selector = 1;
  58. // The requirements for OAuth credentials.
  59. OAuthRequirements oauth = 2;
  60. // If true, the service accepts API keys without any other credential.
  61. bool allow_without_credential = 5;
  62. // Requirements for additional authentication providers.
  63. repeated AuthRequirement requirements = 7;
  64. }
  65. // Configuration for an authentication provider, including support for
  66. // [JSON Web Token
  67. // (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
  68. message AuthProvider {
  69. // The unique identifier of the auth provider. It will be referred to by
  70. // `AuthRequirement.provider_id`.
  71. //
  72. // Example: "bookstore_auth".
  73. string id = 1;
  74. // Identifies the principal that issued the JWT. See
  75. // https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1
  76. // Usually a URL or an email address.
  77. //
  78. // Example: https://securetoken.google.com
  79. // Example: 1234567-compute@developer.gserviceaccount.com
  80. string issuer = 2;
  81. // URL of the provider's public key set to validate signature of the JWT. See
  82. // [OpenID
  83. // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
  84. // Optional if the key set document:
  85. // - can be retrieved from
  86. // [OpenID
  87. // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html of
  88. // the issuer.
  89. // - can be inferred from the email domain of the issuer (e.g. a Google
  90. // service account).
  91. //
  92. // Example: https://www.googleapis.com/oauth2/v1/certs
  93. string jwks_uri = 3;
  94. // The list of JWT
  95. // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
  96. // that are allowed to access. A JWT containing any of these audiences will
  97. // be accepted. When this setting is absent, only JWTs with audience
  98. // "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
  99. // will be accepted. For example, if no audiences are in the setting,
  100. // LibraryService API will only accept JWTs with the following audience
  101. // "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
  102. //
  103. // Example:
  104. //
  105. // audiences: bookstore_android.apps.googleusercontent.com,
  106. // bookstore_web.apps.googleusercontent.com
  107. string audiences = 4;
  108. // Redirect URL if JWT token is required but not present or is expired.
  109. // Implement authorizationUrl of securityDefinitions in OpenAPI spec.
  110. string authorization_url = 5;
  111. }
  112. // OAuth scopes are a way to define data and permissions on data. For example,
  113. // there are scopes defined for "Read-only access to Google Calendar" and
  114. // "Access to Cloud Platform". Users can consent to a scope for an application,
  115. // giving it permission to access that data on their behalf.
  116. //
  117. // OAuth scope specifications should be fairly coarse grained; a user will need
  118. // to see and understand the text description of what your scope means.
  119. //
  120. // In most cases: use one or at most two OAuth scopes for an entire family of
  121. // products. If your product has multiple APIs, you should probably be sharing
  122. // the OAuth scope across all of those APIs.
  123. //
  124. // When you need finer grained OAuth consent screens: talk with your product
  125. // management about how developers will use them in practice.
  126. //
  127. // Please note that even though each of the canonical scopes is enough for a
  128. // request to be accepted and passed to the backend, a request can still fail
  129. // due to the backend requiring additional scopes or permissions.
  130. message OAuthRequirements {
  131. // The list of publicly documented OAuth scopes that are allowed access. An
  132. // OAuth token containing any of these scopes will be accepted.
  133. //
  134. // Example:
  135. //
  136. // canonical_scopes: https://www.googleapis.com/auth/calendar,
  137. // https://www.googleapis.com/auth/calendar.read
  138. string canonical_scopes = 1;
  139. }
  140. // User-defined authentication requirements, including support for
  141. // [JSON Web Token
  142. // (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
  143. message AuthRequirement {
  144. // [id][google.api.AuthProvider.id] from authentication provider.
  145. //
  146. // Example:
  147. //
  148. // provider_id: bookstore_auth
  149. string provider_id = 1;
  150. // NOTE: This will be deprecated soon, once AuthProvider.audiences is
  151. // implemented and accepted in all the runtime components.
  152. //
  153. // The list of JWT
  154. // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
  155. // that are allowed to access. A JWT containing any of these audiences will
  156. // be accepted. When this setting is absent, only JWTs with audience
  157. // "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
  158. // will be accepted. For example, if no audiences are in the setting,
  159. // LibraryService API will only accept JWTs with the following audience
  160. // "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
  161. //
  162. // Example:
  163. //
  164. // audiences: bookstore_android.apps.googleusercontent.com,
  165. // bookstore_web.apps.googleusercontent.com
  166. string audiences = 2;
  167. }