apigeecli 0.53.3__tar.gz → 0.53.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. {apigeecli-0.53.3 → apigeecli-0.53.5}/LICENSE +0 -0
  2. {apigeecli-0.53.3 → apigeecli-0.53.5}/NOTICE +0 -0
  3. {apigeecli-0.53.3/apigeecli.egg-info → apigeecli-0.53.5}/PKG-INFO +34 -29
  4. {apigeecli-0.53.3 → apigeecli-0.53.5}/README.rst +29 -27
  5. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/__init__.py +3 -3
  6. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/__main__.py +0 -0
  7. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apiproducts/__init__.py +0 -0
  8. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apiproducts/apiproducts.py +0 -0
  9. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apiproducts/commands.py +0 -0
  10. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apiproducts/serializer.py +0 -0
  11. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apis/__init__.py +0 -0
  12. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apis/api_puller_with_dependency_extraction.py +0 -0
  13. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apis/apis.py +0 -0
  14. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apis/commands.py +0 -0
  15. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apis/deploy.py +0 -0
  16. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apis/serializer.py +0 -0
  17. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apps/__init__.py +0 -0
  18. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apps/apps.py +0 -0
  19. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apps/commands.py +0 -0
  20. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/apps/serializer.py +0 -0
  21. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/auth.py +40 -52
  22. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/backups/__init__.py +0 -0
  23. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/backups/backups.py +0 -0
  24. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/backups/commands.py +0 -0
  25. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/caches/__init__.py +0 -0
  26. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/caches/caches.py +0 -0
  27. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/caches/commands.py +0 -0
  28. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/caches/serializer.py +0 -0
  29. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/cls.py +0 -0
  30. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/configure/__init__.py +0 -0
  31. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/configure/commands.py +0 -0
  32. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/console.py +0 -0
  33. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/crypto.py +0 -0
  34. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/deployments/__init__.py +0 -0
  35. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/deployments/commands.py +0 -0
  36. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/deployments/deployments.py +0 -0
  37. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/deployments/serializer.py +0 -0
  38. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/developers/__init__.py +0 -0
  39. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/developers/commands.py +0 -0
  40. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/developers/developers.py +0 -0
  41. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/developers/serializer.py +0 -0
  42. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/encryption_utils.py +12 -14
  43. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/exceptions.py +0 -0
  44. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keystores/__init__.py +0 -0
  45. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keystores/commands.py +0 -0
  46. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keystores/keystores.py +0 -0
  47. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keystores/serializer.py +0 -0
  48. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keyvaluemaps/__init__.py +0 -0
  49. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keyvaluemaps/commands.py +0 -0
  50. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keyvaluemaps/keyvaluemaps.py +0 -0
  51. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/keyvaluemaps/serializer.py +0 -0
  52. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/maskconfigs/__init__.py +0 -0
  53. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/maskconfigs/commands.py +0 -0
  54. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/maskconfigs/maskconfigs.py +0 -0
  55. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/maskconfigs/serializer.py +0 -0
  56. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/permissions/__init__.py +0 -0
  57. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/permissions/commands.py +0 -0
  58. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/permissions/permissions.py +0 -0
  59. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/permissions/serializer.py +0 -0
  60. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/plugins/__init__.py +0 -0
  61. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/plugins/commands.py +0 -0
  62. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/prefix.py +0 -0
  63. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/references/__init__.py +0 -0
  64. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/references/commands.py +0 -0
  65. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/references/references.py +0 -0
  66. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/references/serializer.py +0 -0
  67. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/sharedflows/__init__.py +0 -0
  68. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/sharedflows/commands.py +0 -0
  69. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/sharedflows/serializer.py +0 -0
  70. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/sharedflows/sharedflows.py +0 -0
  71. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/silent.py +0 -0
  72. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/targetservers/__init__.py +0 -0
  73. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/targetservers/commands.py +0 -0
  74. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/targetservers/serializer.py +0 -0
  75. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/targetservers/targetservers.py +0 -0
  76. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/types.py +0 -0
  77. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/userroles/__init__.py +0 -0
  78. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/userroles/commands.py +0 -0
  79. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/userroles/userroles.py +0 -0
  80. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/utils.py +0 -0
  81. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/utils_init.py +0 -0
  82. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/verbose.py +0 -0
  83. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/virtualhosts/__init__.py +0 -0
  84. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/virtualhosts/commands.py +0 -0
  85. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/virtualhosts/serializer.py +0 -0
  86. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigee/virtualhosts/virtualhosts.py +0 -0
  87. {apigeecli-0.53.3 → apigeecli-0.53.5/apigeecli.egg-info}/PKG-INFO +34 -29
  88. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigeecli.egg-info/SOURCES.txt +4 -2
  89. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigeecli.egg-info/dependency_links.txt +0 -0
  90. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigeecli.egg-info/entry_points.txt +1 -0
  91. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigeecli.egg-info/requires.txt +3 -3
  92. {apigeecli-0.53.3 → apigeecli-0.53.5}/apigeecli.egg-info/top_level.txt +0 -0
  93. {apigeecli-0.53.3 → apigeecli-0.53.5}/setup.cfg +0 -0
  94. {apigeecli-0.53.3 → apigeecli-0.53.5}/setup.py +0 -0
  95. {apigeecli-0.53.3 → apigeecli-0.53.5}/tests/__init__.py +0 -0
  96. apigeecli-0.53.5/tests/test_auth.py +63 -0
  97. apigeecli-0.53.5/tests/test_echo.py +35 -0
  98. apigeecli-0.53.5/tests/test_encryption_utils.py +32 -0
  99. apigeecli-0.53.3/apigee/apis/pull.py +0 -255
File without changes
File without changes
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: apigeecli
3
- Version: 0.53.3
4
- Summary: apigee-cli is an unofficial command-line interface tool designed to simplify the use of the Apigee Edge Management API
3
+ Version: 0.53.5
4
+ Summary: The Apigee Edge command-line interface is an unofficial Python command-line tool built to simplify and automate Apigee Edge API usage, with support for SSO, MFA, and basic authentication.
5
5
  Home-page: https://github.com/darumatic/apigee-cli
6
6
  Author: Matthew Delotavo
7
7
  Author-email: matthew.t.delotavo@gmail.com
8
8
  License: Apache license 2.0
9
9
  Project-URL: Documentation, https://darumatic.github.io/apigee-cli/index.html
10
+ Platform: UNKNOWN
10
11
  Classifier: Development Status :: 4 - Beta
11
12
  Classifier: Environment :: Console
12
13
  Classifier: Intended Audience :: Developers
@@ -22,23 +23,25 @@ License-File: NOTICE
22
23
  apigee-cli
23
24
  ==========
24
25
 
25
- ⚠️ **Warning:** This project is no longer actively maintained and was created specifically for previous Darumatic clients.
26
+ |Python version| |Downloads| |License|
26
27
 
27
- |License| |Python version| |Downloads|
28
+ .. warning::
28
29
 
29
- apigee-cli is a command-line interface tool designed to simplify the use of the Apigee Edge Management API.
30
- It provides a user-friendly experience with features such as SSO support.
30
+ This tool is no longer actively maintained.
31
31
 
32
- It can be used for general administrative tasks, as a developer package,
33
- and to support automation for common development tasks such as CI/CD.
32
+ The Apigee Edge command-line interface is an unofficial Python command-line tool built to simplify and automate Apigee Edge API usage, with support for SSO, MFA, and basic authentication.
34
33
 
35
- With the apigee-cli, you can manage your Apigee Edge credentials using environment variables, config files,
36
- or command-line arguments.
34
+ Initially developed for Darumatic clients, this project remains available as a working proof of concept, proven reliable in production CI/CD pipelines. The custom plugins feature will remain functional even if Apigee Edge APIs stop working.
37
35
 
38
- The tool is highly experimental and is not affiliated with Apigee or Google.
36
+ I have created private forks for clients, where I continued to add features, fixes, and unit tests. However, I do not intend to maintain this public version. Feel free to explore and learn from the code.
39
37
 
40
- For more information on getting started with the apigee-cli or for troubleshooting help,
41
- refer to the documentation and links provided.
38
+ If you’re up for a challenge, try updating the code to work with Apigee X (ง•_•)ง
39
+
40
+ -----------------------------------------
41
+ Why use this instead of the official tool
42
+ -----------------------------------------
43
+
44
+ The `official Apigee CLI`_ is powerful and may suit your needs. However, I built this version to better support our CI/CD processes, self-service operations, and DevOps workflows that are difficult to manage with the official tool.
42
45
 
43
46
  ------------
44
47
  Installation
@@ -125,24 +128,23 @@ Run the following command to get a list of API proxies in your ``default`` Apige
125
128
  $ apigee apis list
126
129
  ["helloworld", "oauth"]
127
130
 
128
- --------------------
129
- Why does this exist?
130
- --------------------
131
+ -------------
132
+ Running Tests
133
+ -------------
134
+
135
+ This project uses `unittest` for testing its codebase. In order to run the tests, you will need to install the `coverage.py` tool. You can install it using pip:
136
+
137
+ .. code-block:: bash
131
138
 
132
- It is intended for general administrative use from your shell, as a package for developers,
133
- and to support automation for common development tasks, such as test automation
134
- or Continuous Integration/Continuous Deployment (CI/CD).
139
+ pip3 install coverage
135
140
 
136
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
137
- When to use this over the official tool
138
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141
+ Once `coverage.py` is installed, you can run the tests using the `runtests` script:
139
142
 
140
- Apigee Corporation maintains their own `fully-featured CLI`_ for the Apigee Management API
141
- that can be used as an SDK to orchestrate tasks and may be more than suitable for your needs.
143
+ .. code-block:: bash
142
144
 
143
- We built and use the Apigee CLI to implement and distribute features that allow our clients
144
- to manage CI/CD, perform self-service operations and promote our DevOps workflows
145
- which are difficult to perform using official tools.
145
+ ./runtests
146
+
147
+ This script will run all the tests in the `tests` directory and generate a coverage report.
146
148
 
147
149
  ------------
148
150
  Getting Help
@@ -163,10 +165,11 @@ For further questions, feel free to contact us at hello@darumatic.com.
163
165
  ----------
164
166
  Disclaimer
165
167
  ----------
166
- This is not an officially supported Google product.
168
+
169
+ This tool is not affiliated with Apigee or Google and is highly experimental.
167
170
 
168
171
 
169
- .. _`fully-featured CLI`: https://github.com/apigee/apigeetool-node
172
+ .. _`official Apigee CLI`: https://github.com/apigee/apigeetool-node
170
173
 
171
174
  .. |Upload Python Package badge| image:: https://github.com/mdelotavo/apigee-cli/workflows/Upload%20Python%20Package/badge.svg
172
175
  :target: https://github.com/mdelotavo/apigee-cli/actions?query=workflow%3A%22Upload+Python+Package%22
@@ -224,3 +227,5 @@ This is not an officially supported Google product.
224
227
 
225
228
  .. _`Apigee CI/CD Docker releases`: https://hub.docker.com/r/darumatic/apigee-cicd
226
229
 
230
+
231
+
@@ -2,23 +2,25 @@
2
2
  apigee-cli
3
3
  ==========
4
4
 
5
- ⚠️ **Warning:** This project is no longer actively maintained and was created specifically for previous Darumatic clients.
5
+ |Python version| |Downloads| |License|
6
6
 
7
- |License| |Python version| |Downloads|
7
+ .. warning::
8
8
 
9
- apigee-cli is a command-line interface tool designed to simplify the use of the Apigee Edge Management API.
10
- It provides a user-friendly experience with features such as SSO support.
9
+ This tool is no longer actively maintained.
11
10
 
12
- It can be used for general administrative tasks, as a developer package,
13
- and to support automation for common development tasks such as CI/CD.
11
+ The Apigee Edge command-line interface is an unofficial Python command-line tool built to simplify and automate Apigee Edge API usage, with support for SSO, MFA, and basic authentication.
14
12
 
15
- With the apigee-cli, you can manage your Apigee Edge credentials using environment variables, config files,
16
- or command-line arguments.
13
+ Initially developed for Darumatic clients, this project remains available as a working proof of concept, proven reliable in production CI/CD pipelines. The custom plugins feature will remain functional even if Apigee Edge APIs stop working.
17
14
 
18
- The tool is highly experimental and is not affiliated with Apigee or Google.
15
+ I have created private forks for clients, where I continued to add features, fixes, and unit tests. However, I do not intend to maintain this public version. Feel free to explore and learn from the code.
19
16
 
20
- For more information on getting started with the apigee-cli or for troubleshooting help,
21
- refer to the documentation and links provided.
17
+ If you’re up for a challenge, try updating the code to work with Apigee X (ง•_•)ง
18
+
19
+ -----------------------------------------
20
+ Why use this instead of the official tool
21
+ -----------------------------------------
22
+
23
+ The `official Apigee CLI`_ is powerful and may suit your needs. However, I built this version to better support our CI/CD processes, self-service operations, and DevOps workflows that are difficult to manage with the official tool.
22
24
 
23
25
  ------------
24
26
  Installation
@@ -105,24 +107,23 @@ Run the following command to get a list of API proxies in your ``default`` Apige
105
107
  $ apigee apis list
106
108
  ["helloworld", "oauth"]
107
109
 
108
- --------------------
109
- Why does this exist?
110
- --------------------
110
+ -------------
111
+ Running Tests
112
+ -------------
113
+
114
+ This project uses `unittest` for testing its codebase. In order to run the tests, you will need to install the `coverage.py` tool. You can install it using pip:
111
115
 
112
- It is intended for general administrative use from your shell, as a package for developers,
113
- and to support automation for common development tasks, such as test automation
114
- or Continuous Integration/Continuous Deployment (CI/CD).
116
+ .. code-block:: bash
115
117
 
116
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117
- When to use this over the official tool
118
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118
+ pip3 install coverage
119
119
 
120
- Apigee Corporation maintains their own `fully-featured CLI`_ for the Apigee Management API
121
- that can be used as an SDK to orchestrate tasks and may be more than suitable for your needs.
120
+ Once `coverage.py` is installed, you can run the tests using the `runtests` script:
122
121
 
123
- We built and use the Apigee CLI to implement and distribute features that allow our clients
124
- to manage CI/CD, perform self-service operations and promote our DevOps workflows
125
- which are difficult to perform using official tools.
122
+ .. code-block:: bash
123
+
124
+ ./runtests
125
+
126
+ This script will run all the tests in the `tests` directory and generate a coverage report.
126
127
 
127
128
  ------------
128
129
  Getting Help
@@ -143,10 +144,11 @@ For further questions, feel free to contact us at hello@darumatic.com.
143
144
  ----------
144
145
  Disclaimer
145
146
  ----------
146
- This is not an officially supported Google product.
147
+
148
+ This tool is not affiliated with Apigee or Google and is highly experimental.
147
149
 
148
150
 
149
- .. _`fully-featured CLI`: https://github.com/apigee/apigeetool-node
151
+ .. _`official Apigee CLI`: https://github.com/apigee/apigeetool-node
150
152
 
151
153
  .. |Upload Python Package badge| image:: https://github.com/mdelotavo/apigee-cli/workflows/Upload%20Python%20Package/badge.svg
152
154
  :target: https://github.com/mdelotavo/apigee-cli/actions?query=workflow%3A%22Upload+Python+Package%22
@@ -6,9 +6,9 @@ from apigee import utils_init
6
6
 
7
7
  APP = "apigeecli"
8
8
  CMD = "apigee"
9
- __version__ = "0.53.3"
10
- description = "apigee-cli is an unofficial command-line interface tool designed to simplify the use of the Apigee Edge Management API"
11
- long_description = """apigee-cli is an unofficial command-line interface tool designed to simplify the use of the Apigee Edge Management API. It provides a user-friendly experience with features such as SSO support. It can be used for general administrative tasks, as a developer package, and to support automation for common development tasks such as CI/CD. With the apigee-cli, you can manage your Apigee Edge credentials using environment variables, config files, or command-line arguments. The tool is highly experimental and is not affiliated with Apigee or Google. For more information on getting started with the apigee-cli or for troubleshooting help, refer to the documentation and links provided."""
9
+ __version__ = "0.53.5"
10
+ description = "The Apigee Edge command-line interface is an unofficial Python command-line tool built to simplify and automate Apigee Edge API usage, with support for SSO, MFA, and basic authentication."
11
+ long_description = """This tool is no longer actively maintained. Initially developed for Darumatic clients, this project remains available as a working proof of concept, proven reliable in production CI/CD pipelines. The custom plugins feature will remain functional even if Apigee Edge APIs stop working."""
12
12
 
13
13
  APIGEE_CLI_DIRECTORY = utils_init.join_path_components(Path.home(), ".apigee")
14
14
  APIGEE_CLI_PLUGINS_DIRECTORY = utils_init.join_path_components(APIGEE_CLI_DIRECTORY, "plugins")
@@ -37,21 +37,21 @@ def attach_is_token_option(func, profile):
37
37
  "--token/--no-token",
38
38
  default=is_token,
39
39
  show_default=True,
40
- help="specify to use oauth without MFA",
40
+ help="specify to use OAuth without MFA",
41
41
  )(func)
42
42
  elif is_token_envvar in (True, "True", "true", "1"):
43
43
  func = click.option(
44
44
  "--token/--no-token",
45
45
  default=is_token_envvar,
46
46
  show_default=True,
47
- help="specify to use oauth without MFA",
47
+ help="specify to use OAuth without MFA",
48
48
  )(func)
49
49
  else:
50
50
  func = click.option(
51
51
  "--token/--no-token",
52
52
  default=False,
53
53
  show_default=True,
54
- help="specify to use oauth without MFA",
54
+ help="specify to use OAuth without MFA",
55
55
  )(func)
56
56
  return func
57
57
 
@@ -222,75 +222,68 @@ def get_access_token_for_mfa(
222
222
  )
223
223
 
224
224
 
225
- def get_access_token(auth, username, password, oauth_url, post_headers, session):
225
+ def get_access_token(auth, username, password, oauth_url, post_headers, session, passcode):
226
226
  if auth.token or APIGEE_CLI_IS_MACHINE_USER:
227
227
  return get_access_token_for_token(auth, username, password, oauth_url, post_headers, session)
228
228
  elif auth.mfa_secret:
229
229
  return get_access_token_for_mfa(auth, username, password, oauth_url, post_headers, session)
230
230
  elif auth.zonename:
231
- return get_access_token_for_sso(auth, username, password, oauth_url, post_headers, session)
231
+ return get_access_token_for_sso(auth, username, password, oauth_url, post_headers, session, passcode)
232
232
 
233
233
 
234
234
  def get_access_token_for_sso(
235
- auth, username, password, oauth_url, post_headers, session
235
+ auth, username, password, oauth_url, post_headers, session, passcode
236
236
  ):
237
237
  refresh_token = validate_refresh_token(auth)
238
238
  oauth_url = APIGEE_ZONENAME_OAUTH_URL.format(zonename=auth.zonename)
239
239
  passcode_url = APIGEE_SAML_LOGIN_URL.format(zonename=auth.zonename)
240
+
240
241
  if not refresh_token:
241
- post_body = get_sso_access_token_parameters(passcode_url)
242
+ if not passcode:
243
+ passcode = get_sso_temporary_authentication_code(passcode_url)
244
+ post_body = f"passcode={passcode}&grant_type=password&response_type=token"
242
245
  else:
243
246
  # Should we notify users that the refresh token is being used to verify the access token?
244
247
  #console.echo("Refresh Token found, renewing access token with Refresh Token...")
245
248
  post_body = f"grant_type=refresh_token&refresh_token={refresh_token}"
246
249
 
247
250
  try:
248
- try:
249
- response_post = session.post(
250
- f"{oauth_url}", headers=post_headers, data=post_body
251
- )
252
- response_data = response_post.json()
253
- response_data["access_token"]
254
- # If we didn't have a refresh token previously, save the refresh token we just got.
255
- if not refresh_token:
256
- with open(APIGEE_CLI_REFRESH_TOKEN_FILE, "w") as f:
257
- f.write(response_data["refresh_token"])
258
- return response_data
259
- except KeyError:
260
- sys.exit("Temporary Authentication Code or Refresh Token is invalid. Please try again.")
251
+ response_post = session.post(
252
+ f"{oauth_url}", headers=post_headers, data=post_body
253
+ )
254
+ response_data = response_post.json()
255
+ response_data["access_token"]
256
+
257
+ # If we didn't have a refresh token previously, save the refresh token we just got.
258
+ if not refresh_token:
259
+ with open(APIGEE_CLI_REFRESH_TOKEN_FILE, "w") as f:
260
+ f.write(response_data["refresh_token"])
261
+ return response_data
262
+ except KeyError:
263
+ sys.exit("Temporary Authentication Code or Refresh Token is invalid. Please try again.")
261
264
  except ConnectionError as ce:
262
265
  console.echo(ce)
263
- except KeyError:
264
- pass
265
266
 
266
267
 
267
268
  def get_config_value(config_section, config_key):
268
- try:
269
- config = configparser.ConfigParser()
270
- config.read(APIGEE_CLI_CREDENTIALS_FILE)
271
- if config_section in config:
269
+ config = configparser.ConfigParser()
270
+ config.read(APIGEE_CLI_CREDENTIALS_FILE)
271
+ if config_section in config:
272
+ if config_key in config[config_section]:
272
273
  return config[config_section][config_key]
273
- except Exception:
274
- return
275
274
 
276
275
 
277
- def get_sso_access_token_parameters(passcode_url):
276
+ def get_sso_temporary_authentication_code(passcode_url):
278
277
  webbrowser.open(passcode_url)
279
- console.echo(
280
- "SSO authorization page has automatically been opened in your default browser."
281
- )
282
- console.echo(
283
- "Follow the instructions in the browser to complete this authorization request."
284
- )
285
- console.echo(
286
- f"""\nIf your browser did not automatically open, go to the following URL and sign in:\n\n{passcode_url}\n\nthen copy the Temporary Authentication Code.\n"""
287
- )
278
+ console.echo("SSO authorization page has automatically been opened in your default browser.")
279
+ console.echo("Follow the instructions in the browser to complete this authorization request.")
280
+ console.echo(f"""\nIf your browser did not automatically open, go to the following URL and sign in:\n\n{passcode_url}\n\nthen copy the Temporary Authentication Code.\n""")
288
281
 
289
282
  passcode = click.prompt("Please enter the Temporary Authentication Code")
290
- return f"passcode={passcode}&grant_type=password&response_type=token"
283
+ return passcode
291
284
 
292
285
 
293
- def retrieve_access_token(authentication, session=None):
286
+ def retrieve_access_token(authentication, passcode=None):
294
287
  oauth_url = APIGEE_OAUTH_URL
295
288
  username = authentication.username
296
289
  password = authentication.password
@@ -302,7 +295,7 @@ def retrieve_access_token(authentication, session=None):
302
295
  "Accept": "application/json;charset=utf-8",
303
296
  "Authorization": "Basic ZWRnZWNsaTplZGdlY2xpc2VjcmV0",
304
297
  }
305
- response_data = get_access_token(authentication, username, password, oauth_url, post_headers, session)
298
+ response_data = get_access_token(authentication, username, password, oauth_url, post_headers, session, passcode)
306
299
  try:
307
300
  return response_data["access_token"]
308
301
  except KeyError as error:
@@ -366,19 +359,18 @@ def auth():
366
359
  pass
367
360
 
368
361
 
369
- @auth.command(name="get-access-token", help="request a fresh access token")
362
+ @auth.command(name="get-access-token", help="Request a fresh access token")
370
363
  @common_auth_options
371
364
  @common_verbose_options
372
365
  @common_silent_options
366
+ @click.option('--passcode', help='Apigee SAML temporary authentication code to use when getting an Apigee access token (optional)')
373
367
  def get_access_token_command(
374
- username, password, mfa_secret, token, zonename, org, profile, **kwargs
368
+ username, password, mfa_secret, token, zonename, org, profile, passcode, **kwargs
375
369
  ):
376
- console.echo(
377
- retrieve_access_token(generate_authentication(username, password, mfa_secret, token, zonename))
378
- )
370
+ console.echo(retrieve_access_token(generate_authentication(username, password, mfa_secret, token, zonename), passcode))
379
371
 
380
372
 
381
- @auth.command(help="view the current access token")
373
+ @auth.command(help="View the current access token")
382
374
  @common_auth_options
383
375
  @common_verbose_options
384
376
  @common_silent_options
@@ -392,11 +384,7 @@ def view_access_token(
392
384
  console.echo(validate_access_token(authentication_object))
393
385
  else:
394
386
  # Show the user/password base64 basic auth value
395
- console.echo(
396
- base64.b64encode(
397
- f"{authentication_object.username}:{authentication_object.password}".encode()
398
- ).decode()
399
- )
387
+ console.echo(base64.b64encode(f"{authentication_object.username}:{authentication_object.password}".encode()).decode())
400
388
 
401
389
 
402
390
  @auth.command(help="Clear cached access token and refresh token")
File without changes
File without changes
File without changes
@@ -1,5 +1,4 @@
1
1
  import base64
2
-
3
2
  import gnupg
4
3
 
5
4
  ENCRYPTED_HEADER_BEGIN = "-----BEGIN ENCRYPTED APIGEE CLI MESSAGE-----"
@@ -8,22 +7,20 @@ ENCRYPTED_HEADER_END = "-----END ENCRYPTED APIGEE CLI MESSAGE-----"
8
7
 
9
8
  def encrypt_message_with_gpg(secret, message, encoded=True):
10
9
  gpg = gnupg.GPG()
11
- if encoded:
12
- return base64.b64encode(
13
- str(
14
- gpg.encrypt(
15
- message, symmetric="AES256", passphrase=secret, recipients=None
16
- )
17
- ).encode()
18
- ).decode()
19
- return str(
20
- gpg.encrypt(message, symmetric="AES256", passphrase=secret, recipients=None)
10
+ encrypted_message = gpg.encrypt(
11
+ message, symmetric="AES256", passphrase=secret, recipients=None
21
12
  )
13
+ if encoded:
14
+ return base64.b64encode(str(encrypted_message).encode()).decode()
15
+ return str(encrypted_message)
22
16
 
23
17
 
24
18
  def has_encrypted_header(message):
25
- return message.startswith(ENCRYPTED_HEADER_BEGIN) and message.endswith(
26
- ENCRYPTED_HEADER_END
19
+ if not isinstance(message, str):
20
+ return False
21
+ return (
22
+ message.startswith(ENCRYPTED_HEADER_BEGIN)
23
+ and message.endswith(ENCRYPTED_HEADER_END)
27
24
  )
28
25
 
29
26
 
@@ -33,5 +30,6 @@ def decrypt_message_with_gpg(secret, message, encoded=True):
33
30
  return ""
34
31
  message = message[len(ENCRYPTED_HEADER_BEGIN) : -len(ENCRYPTED_HEADER_END)]
35
32
  if encoded:
36
- return str(gpg.decrypt(base64.b64decode(message).decode(), passphrase=secret))
33
+ decoded_message = base64.b64decode(message).decode()
34
+ return str(gpg.decrypt(decoded_message, passphrase=secret))
37
35
  return str(gpg.decrypt(message, passphrase=secret))
File without changes
File without changes
File without changes