| OLD | NEW |
| 1 # -*- coding: utf-8 -*- |
| 1 # Copyright 2013 Google Inc. All Rights Reserved. | 2 # Copyright 2013 Google Inc. All Rights Reserved. |
| 2 # | 3 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # 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 not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
| 6 # | 7 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 9 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 11 # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 # See the License for the specific language governing permissions and | 13 # See the License for the specific language governing permissions and |
| 13 # limitations under the License. | 14 # limitations under the License. |
| 15 """Additional help about types of credentials and authentication.""" |
| 14 | 16 |
| 15 from gslib.help_provider import HELP_NAME | 17 from __future__ import absolute_import |
| 16 from gslib.help_provider import HELP_NAME_ALIASES | 18 |
| 17 from gslib.help_provider import HELP_ONE_LINE_SUMMARY | |
| 18 from gslib.help_provider import HelpProvider | 19 from gslib.help_provider import HelpProvider |
| 19 from gslib.help_provider import HELP_TEXT | |
| 20 from gslib.help_provider import HelpType | |
| 21 from gslib.help_provider import HELP_TYPE | |
| 22 | 20 |
| 23 _detailed_help_text = (""" | 21 _DETAILED_HELP_TEXT = (""" |
| 24 <B>OVERVIEW</B> | 22 <B>OVERVIEW</B> |
| 25 gsutil currently supports four types of credentials/authentication, as well as | 23 gsutil currently supports four types of credentials/authentication, as well as |
| 26 the ability to access public data anonymously (see "gsutil help anon" for more | 24 the ability to access public data anonymously (see "gsutil help anon" for more |
| 27 on anonymous access). | 25 on anonymous access). |
| 28 | 26 |
| 27 Note that when using the JSON API (which is the default behavior), you can |
| 28 configure at most one of the following types of GCS credentials in a single |
| 29 boto config file: OAuth2 User Account, OAuth2 Service Account. In addition to |
| 30 these, you may also have S3 HMAC credentials (necessary for using s3:// URLs) |
| 31 and GCE Internal Service Account credentials. GCE Internal Service Account |
| 32 credentials are used only when OAuth2 credentials are not present. |
| 33 |
| 29 OAuth2 User Account: | 34 OAuth2 User Account: |
| 30 This is the preferred type of credentials for authenticating requests on | 35 This is the preferred type of credentials for authenticating requests on |
| 31 behalf of a specific user (which is probably the most common use of gsutil). | 36 behalf of a specific user (which is probably the most common use of gsutil). |
| 32 This is the default type of credential that will be created when you run | 37 This is the default type of credential that will be created when you run |
| 33 "gsutil config". | 38 "gsutil config". |
| 34 For more details about OAuth2 authentication, see: | 39 For more details about OAuth2 authentication, see: |
| 35 https://developers.google.com/accounts/docs/OAuth2#scenarios | 40 https://developers.google.com/accounts/docs/OAuth2#scenarios |
| 36 | 41 |
| 37 HMAC: | 42 HMAC: |
| 38 This type of credential can be used by programs that are implemented using | 43 This type of credential can be used by programs that are implemented using |
| (...skipping 16 matching lines...) Expand all Loading... |
| 55 OAuth2 Service Account: | 60 OAuth2 Service Account: |
| 56 This is the preferred type of credential to use when authenticating on | 61 This is the preferred type of credential to use when authenticating on |
| 57 behalf of a service or application (as opposed to a user). For example, if | 62 behalf of a service or application (as opposed to a user). For example, if |
| 58 you will run gsutil out of a nightly cron job to upload/download data, | 63 you will run gsutil out of a nightly cron job to upload/download data, |
| 59 using a service account allows the cron job not to depend on credentials of | 64 using a service account allows the cron job not to depend on credentials of |
| 60 an individual employee at your company. This is the type of credential that | 65 an individual employee at your company. This is the type of credential that |
| 61 will be configured when you run "gsutil config -e". | 66 will be configured when you run "gsutil config -e". |
| 62 | 67 |
| 63 It is important to note that a service account is considered an Editor by | 68 It is important to note that a service account is considered an Editor by |
| 64 default for the purposes of API access, rather than an Owner. In particular, | 69 default for the purposes of API access, rather than an Owner. In particular, |
| 65 the fact that Editors have full_control access in the default object and | 70 the fact that Editors have OWNER access in the default object and |
| 66 bucket ACLs, but the canned ACL options remove full_control access from | 71 bucket ACLs, but the canned ACL options remove OWNER access from |
| 67 Editors, can lead to unexpected results. The solution to this problem is to | 72 Editors, can lead to unexpected results. The solution to this problem is to |
| 68 add the email address for your service account as a project Owner. To find | 73 add the email address for your service account as a project Owner. To find |
| 69 the email address, visit the `Google Cloud Console | 74 the email address, visit the |
| 70 <https://cloud.google.com/console#/project>`_, click on the project you | 75 `Google Developers Console <https://cloud.google.com/console#/project>`_, |
| 71 are using, then click "APIs & auth", then click "Registered apps", then | 76 click on the project you're using, click "APIs & auth", and click |
| 72 click on the name of the registered app. (Note: for service accounts created | 77 "Credentials". |
| 73 via the older API Developer's Console, the name will be something like | |
| 74 "Service Account-<service account id>".) This page lists the email address | |
| 75 of your service account. | |
| 76 | 78 |
| 77 To create a service account, visit the Google Cloud Console and then: | 79 To create a service account, visit the Google Cloud Console and then: |
| 78 | 80 |
| 79 - Click the APIs tab on the left | 81 - Click the APIs tab on the left |
| 80 | 82 |
| 81 - Click "All Registered Apps" | 83 - Click "APIs & auth" |
| 82 | 84 |
| 83 - Click the red "Register App" button | 85 - Click the red "Create New Client ID" button |
| 84 | 86 |
| 85 - Create a "Web Application" type | 87 - Create a "Service Account" type |
| 86 | 88 |
| 87 - Once that's created, click on the "Certificate" area | 89 - Save the private key and password provided. |
| 88 | |
| 89 - Click the "Generate Certificate" button. | |
| 90 | 90 |
| 91 For further information about account roles, see: | 91 For further information about account roles, see: |
| 92 https://developers.google.com/console/help/#DifferentRoles | 92 https://developers.google.com/console/help/#DifferentRoles |
| 93 | 93 |
| 94 For more details about OAuth2 service accounts, see: | 94 For more details about OAuth2 service accounts, see: |
| 95 https://developers.google.com/accounts/docs/OAuth2ServiceAccount | 95 https://developers.google.com/accounts/docs/OAuth2ServiceAccount |
| 96 | 96 |
| 97 GCE Internal Service Account: | 97 GCE Internal Service Account: |
| 98 This is the type of service account used for accounts hosted by App Engine | 98 This is the type of service account used for accounts hosted by App Engine |
| 99 or GCE. Such credentials are created automatically for you on GCE when you | 99 or GCE. Such credentials are created automatically for you on GCE when you |
| 100 run the gcutil addinstance command with the --service_account flag. | 100 run the gcutil addinstance command with the --service_account flag. |
| 101 | 101 |
| 102 For more details about GCE service accounts, see: | 102 For more details about GCE service accounts, see: |
| 103 https://developers.google.com/compute/docs/authentication; | 103 https://developers.google.com/compute/docs/authentication; |
| 104 | 104 |
| 105 For more details about App Engine service accounts, see: | 105 For more details about App Engine service accounts, see: |
| 106 https://developers.google.com/appengine/docs/python/appidentity/overview | 106 https://developers.google.com/appengine/docs/python/appidentity/overview |
| 107 | 107 |
| 108 """) | 108 """) |
| 109 | 109 |
| 110 | 110 |
| 111 | |
| 112 class CommandOptions(HelpProvider): | 111 class CommandOptions(HelpProvider): |
| 113 """Additional help about types of credentials and authentication.""" | 112 """Additional help about types of credentials and authentication.""" |
| 114 | 113 |
| 115 help_spec = { | 114 # Help specification. See help_provider.py for documentation. |
| 116 # Name of command or auxiliary help info for which this help applies. | 115 help_spec = HelpProvider.HelpSpec( |
| 117 HELP_NAME : 'creds', | 116 help_name='creds', |
| 118 # List of help name aliases. | 117 help_name_aliases=['credentials', 'authentication', 'auth'], |
| 119 HELP_NAME_ALIASES : ['credentials', 'authentication', 'auth'], | 118 help_type='additional_help', |
| 120 # Type of help: | 119 help_one_line_summary='Credential Types Supporting Various Use Cases', |
| 121 HELP_TYPE : HelpType.ADDITIONAL_HELP, | 120 help_text=_DETAILED_HELP_TEXT, |
| 122 # One line summary of this help. | 121 subcommand_help_text={}, |
| 123 HELP_ONE_LINE_SUMMARY : 'Credential Types Supporting Various Use Cases', | 122 ) |
| 124 # The full help text. | |
| 125 HELP_TEXT : _detailed_help_text, | |
| 126 } | |
| OLD | NEW |