Skip to content

Commit

Permalink
Support login with live-id and creds sharing with azure-xplat-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
yugangw-msft committed Apr 6, 2016
1 parent dedb1bb commit 5d718e6
Show file tree
Hide file tree
Showing 11 changed files with 629 additions and 161 deletions.
2 changes: 2 additions & 0 deletions azure-cli.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Compile Include="azure\cli\main.py" />
<Compile Include="azure\cli\tests\command_specs\test_spec_network.py" />
<Compile Include="azure\cli\tests\command_specs\test_spec_resource.py" />
<Compile Include="azure\cli\tests\command_specs\test_spec_storage_account.py" />
<Compile Include="azure\cli\tests\command_specs\test_spec_vm.py" />
<Compile Include="azure\cli\tests\command_specs\__init__.py" />
<Compile Include="azure\cli\parser.py" />
Expand All @@ -54,6 +55,7 @@
<Compile Include="azure\cli\tests\test_connection_verify.py" />
<Compile Include="azure\cli\tests\test_application.py" />
<Compile Include="azure\cli\tests\test_output.py" />
<Compile Include="azure\cli\_azure_env.py" />
<Compile Include="azure\cli\_debug.py" />
<Compile Include="azure\cli\tests\test_help.py" />
<Compile Include="azure\cli\tests\test_output.py" />
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pyyaml==3.11
six==1.10.0
vcrpy==1.7.4

#Same as: -e git+https://github.com/yugangw-msft/azure-activedirectory-library-for-python.git@0.2.0#egg=azure-activedirectory-library-for-python
http://40.112.211.51:8080/packages/adal-0.2.0.zip
#-e git+https://github.com/yugangw-msft/azure-activedirectory-library-for-python@v2.1#egg=azure-activedirectory-library-for-python
http://40.112.211.51:8080/packages/adal-0.2.1.zip
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
]

DEPENDENCIES = [
'adal==0.2.0', #from internal index server.
'adal==0.2.1', #from internal index server.
'applicationinsights',
'argcomplete',
'azure==2.0.0rc1',
Expand Down
43 changes: 43 additions & 0 deletions src/azure/cli/_azure_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
CLIENT_ID = '04b07795-8ddb-461a-bbee-02f9e1bf7b46'

ENV_DEFAULT = 'AzureCloud'
ENV_US_GOVERNMENT = 'AzureUSGovernment'
ENV_CHINA = 'AzureChinaCloud'

COMMON_TENANT = 'common'

#ported from https://github.com/Azure/azure-xplat-cli/blob/dev/lib/util/profile/environment.js
class ENDPOINT_URLS: #pylint: disable=too-few-public-methods,old-style-class,no-init
MANAGEMENT = 'management'
ACTIVE_DIRECTORY_AUTHORITY = 'active_directory_authority'

_environments = {
ENV_DEFAULT: {
ENDPOINT_URLS.MANAGEMENT: 'https://management.core.windows.net/',
ENDPOINT_URLS.ACTIVE_DIRECTORY_AUTHORITY : 'https://login.microsoftonline.com'
},
ENV_CHINA: {
ENDPOINT_URLS.MANAGEMENT: 'https://management.core.chinacloudapi.cn/',
ENDPOINT_URLS.ACTIVE_DIRECTORY_AUTHORITY: 'https://login.chinacloudapi.cn'
},
ENV_US_GOVERNMENT: {
ENDPOINT_URLS.MANAGEMENT: 'https://management.core.usgovcloudapi.net/',
ENDPOINT_URLS.ACTIVE_DIRECTORY_AUTHORITY: 'https://login.microsoftonline.com'
}
}

def get_env(env_name=None):
if env_name is None:
env_name = ENV_DEFAULT
elif env_name not in _environments:
raise ValueError
return _environments[env_name]

def get_authority_url(tenant=None, env_name=None):
env = get_env(env_name)
return env[ENDPOINT_URLS.ACTIVE_DIRECTORY_AUTHORITY] + '/' + (tenant or COMMON_TENANT)

def get_management_endpoint_url(env_name=None):
env = get_env(env_name)
return env[ENDPOINT_URLS.MANAGEMENT]

Loading

0 comments on commit 5d718e6

Please sign in to comment.