auth.proto 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. // Copyright 2015 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. syntax = "proto3";
  15. package google.api;
  16. option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
  17. option java_multiple_files = true;
  18. option java_outer_classname = "AuthProto";
  19. option java_package = "com.google.api";
  20. option objc_class_prefix = "GAPI";
  21. // `Authentication` defines the authentication configuration for API methods
  22. // provided by an API service.
  23. //
  24. // Example:
  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. // - selector: google.calendar.Delegate
  37. // oauth:
  38. // canonical_scopes: https://www.googleapis.com/auth/calendar.read
  39. message Authentication {
  40. // A list of authentication rules that apply to individual API methods.
  41. //
  42. // **NOTE:** All service configuration rules follow "last one wins" order.
  43. repeated AuthenticationRule rules = 3;
  44. // Defines a set of authentication providers that a service supports.
  45. repeated AuthProvider providers = 4;
  46. }
  47. // Authentication rules for the service.
  48. //
  49. // By default, if a method has any authentication requirements, every request
  50. // must include a valid credential matching one of the requirements.
  51. // It's an error to include more than one kind of credential in a single
  52. // request.
  53. //
  54. // If a method doesn't have any auth requirements, request credentials will be
  55. // ignored.
  56. message AuthenticationRule {
  57. // Selects the methods to which this rule applies.
  58. //
  59. // Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
  60. string selector = 1;
  61. // The requirements for OAuth credentials.
  62. OAuthRequirements oauth = 2;
  63. // If true, the service accepts API keys without any other credential.
  64. // This flag only applies to HTTP and gRPC requests.
  65. bool allow_without_credential = 5;
  66. // Requirements for additional authentication providers.
  67. repeated AuthRequirement requirements = 7;
  68. }
  69. // Specifies a location to extract JWT from an API request.
  70. message JwtLocation {
  71. oneof in {
  72. // Specifies HTTP header name to extract JWT token.
  73. string header = 1;
  74. // Specifies URL query parameter name to extract JWT token.
  75. string query = 2;
  76. // Specifies cookie name to extract JWT token.
  77. string cookie = 4;
  78. }
  79. // The value prefix. The value format is "value_prefix{token}"
  80. // Only applies to "in" header type. Must be empty for "in" query type.
  81. // If not empty, the header value has to match (case sensitive) this prefix.
  82. // If not matched, JWT will not be extracted. If matched, JWT will be
  83. // extracted after the prefix is removed.
  84. //
  85. // For example, for "Authorization: Bearer {JWT}",
  86. // value_prefix="Bearer " with a space at the end.
  87. string value_prefix = 3;
  88. }
  89. // Configuration for an authentication provider, including support for
  90. // [JSON Web Token
  91. // (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
  92. message AuthProvider {
  93. // The unique identifier of the auth provider. It will be referred to by
  94. // `AuthRequirement.provider_id`.
  95. //
  96. // Example: "bookstore_auth".
  97. string id = 1;
  98. // Identifies the principal that issued the JWT. See
  99. // https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1
  100. // Usually a URL or an email address.
  101. //
  102. // Example: https://securetoken.google.com
  103. // Example: 1234567-compute@developer.gserviceaccount.com
  104. string issuer = 2;
  105. // URL of the provider's public key set to validate signature of the JWT. See
  106. // [OpenID
  107. // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
  108. // Optional if the key set document:
  109. // - can be retrieved from
  110. // [OpenID
  111. // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html)
  112. // of the issuer.
  113. // - can be inferred from the email domain of the issuer (e.g. a Google
  114. // service account).
  115. //
  116. // Example: https://www.googleapis.com/oauth2/v1/certs
  117. string jwks_uri = 3;
  118. // The list of JWT
  119. // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
  120. // that are allowed to access. A JWT containing any of these audiences will
  121. // be accepted. When this setting is absent, JWTs with audiences:
  122. // - "https://[service.name]/[google.protobuf.Api.name]"
  123. // - "https://[service.name]/"
  124. // will be accepted.
  125. // For example, if no audiences are in the setting, LibraryService API will
  126. // accept JWTs with the following audiences:
  127. // -
  128. // https://library-example.googleapis.com/google.example.library.v1.LibraryService
  129. // - https://library-example.googleapis.com/
  130. //
  131. // Example:
  132. //
  133. // audiences: bookstore_android.apps.googleusercontent.com,
  134. // bookstore_web.apps.googleusercontent.com
  135. string audiences = 4;
  136. // Redirect URL if JWT token is required but not present or is expired.
  137. // Implement authorizationUrl of securityDefinitions in OpenAPI spec.
  138. string authorization_url = 5;
  139. // Defines the locations to extract the JWT. For now it is only used by the
  140. // Cloud Endpoints to store the OpenAPI extension [x-google-jwt-locations]
  141. // (https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#x-google-jwt-locations)
  142. //
  143. // JWT locations can be one of HTTP headers, URL query parameters or
  144. // cookies. The rule is that the first match wins.
  145. //
  146. // If not specified, default to use following 3 locations:
  147. // 1) Authorization: Bearer
  148. // 2) x-goog-iap-jwt-assertion
  149. // 3) access_token query parameter
  150. //
  151. // Default locations can be specified as followings:
  152. // jwt_locations:
  153. // - header: Authorization
  154. // value_prefix: "Bearer "
  155. // - header: x-goog-iap-jwt-assertion
  156. // - query: access_token
  157. repeated JwtLocation jwt_locations = 6;
  158. }
  159. // OAuth scopes are a way to define data and permissions on data. For example,
  160. // there are scopes defined for "Read-only access to Google Calendar" and
  161. // "Access to Cloud Platform". Users can consent to a scope for an application,
  162. // giving it permission to access that data on their behalf.
  163. //
  164. // OAuth scope specifications should be fairly coarse grained; a user will need
  165. // to see and understand the text description of what your scope means.
  166. //
  167. // In most cases: use one or at most two OAuth scopes for an entire family of
  168. // products. If your product has multiple APIs, you should probably be sharing
  169. // the OAuth scope across all of those APIs.
  170. //
  171. // When you need finer grained OAuth consent screens: talk with your product
  172. // management about how developers will use them in practice.
  173. //
  174. // Please note that even though each of the canonical scopes is enough for a
  175. // request to be accepted and passed to the backend, a request can still fail
  176. // due to the backend requiring additional scopes or permissions.
  177. message OAuthRequirements {
  178. // The list of publicly documented OAuth scopes that are allowed access. An
  179. // OAuth token containing any of these scopes will be accepted.
  180. //
  181. // Example:
  182. //
  183. // canonical_scopes: https://www.googleapis.com/auth/calendar,
  184. // https://www.googleapis.com/auth/calendar.read
  185. string canonical_scopes = 1;
  186. }
  187. // User-defined authentication requirements, including support for
  188. // [JSON Web Token
  189. // (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
  190. message AuthRequirement {
  191. // [id][google.api.AuthProvider.id] from authentication provider.
  192. //
  193. // Example:
  194. //
  195. // provider_id: bookstore_auth
  196. string provider_id = 1;
  197. // NOTE: This will be deprecated soon, once AuthProvider.audiences is
  198. // implemented and accepted in all the runtime components.
  199. //
  200. // The list of JWT
  201. // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
  202. // that are allowed to access. A JWT containing any of these audiences will
  203. // be accepted. When this setting is absent, only JWTs with audience
  204. // "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
  205. // will be accepted. For example, if no audiences are in the setting,
  206. // LibraryService API will only accept JWTs with the following audience
  207. // "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
  208. //
  209. // Example:
  210. //
  211. // audiences: bookstore_android.apps.googleusercontent.com,
  212. // bookstore_web.apps.googleusercontent.com
  213. string audiences = 2;
  214. }