Comments (5)
This is going to be sketchy depending on if the user has multi factor auth turned on.
Check out: https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/lib/token-request.js. This what CLI uses.
from azure-armrest.
To expand a little more on my previous comment. It's recommended that service principals (tenant id, application id, client id, client secret) are recommended for use in automation environments.
Username and password authentication is recommended for interactive scenarios.
Azure CLI and PowerShell can help with provisioning of these Azure Active Directory constructs through the following.
$ azure ad
help: Commands to display active directory objects
help:
help: Commands to display active directory applications
help: ad app create [options]
help: ad app delete [options] <object-id>
help:
help: Commands to display active directory groups
help: ad group list [options]
help: ad group show [options]
help:
help: Commands to provide an active directory sub group or member info
help: ad group member list [options] [objectId]
help:
help: Commands to display active directory service principals
help: ad sp list [options]
help: ad sp show [options]
help: ad sp create [options] <application-id>
help: ad sp delete [options] <object-id>
help:
help: Commands to display active directory users
help: ad user list [options]
help: ad user show [options]
help:
help: Options:
help: -h, --help output usage information
from azure-armrest.
@devigned I've tried looking at the source, but I'm just not getting it. This is basically what we're doing now:
tenant_id = 'xxxxxxx'
authority = "https://login.windows.net/"
token_url = authority + tenant_id + "/oauth2/token"
# Use client credentials approach
response = RestClient.post(
token_url,
:grant_type => 'client_credentials',
:client_id => client_id,
:client_secret => client_key,
:resource => resource_id
)
# Get token
token = JSON.parse(response)['access_token']
url = "https://management.azure.com/subscriptions/?api-version=2015-01-01"
# Pass token on all future requests
resp = RestClient.get(
url,
:content_type => 'application/json',
:authorization => 'Bearer ' + token
)
Is it simple to modify this to make it work with username + password? Or more involved?
from azure-armrest.
This is a little late, so I apologize...
If you have multi-factor auth on, you will have to get the token through interactive login. If you'd like to do anything non-interactive, the guidance is to create a service principal. See: https://azure.microsoft.com/en-us/documentation/articles/resource-group-authenticate-service-principal/#authenticate-service-principal-with-password---azure-cli
from azure-armrest.
I think this is pretty much off the table I think, as it appears it would require firing up a web server and listening on an endpoint. We'll stick to service principal authentication.
from azure-armrest.
Related Issues (20)
- Remove Nokogiri, use REXML HOT 2
- StorageAccountService#list_all_private_images results in Errno::ECONNREFUSED HOT 2
- Marketplace Image Support HOT 1
- Switch from rest-client to excon HOT 1
- VirtualMachineImageService#list_all is very slow HOT 1
- Add friendlier handling of 429 and 50x errors HOT 1
- Refactor request methods into a module HOT 1
- StorageAccount#all_blobs consumes lots of memory HOT 1
- Some current test failures on Windows HOT 5
- Test failures on Windows HOT 1
- next_marker_results is busted HOT 1
- VirtualMachineService#delete_associated_resources does not handle managed disks HOT 1
- StorageAccount#table_data with :all option is busted HOT 2
- RFE: AzureStack -- auto-discovery of Azure endpoint URLs HOT 6
- Update rest-client to 2.1.0 HOT 1
- Metrics collection needs to be updated HOT 1
- Azure-armrest fails to properly handle application/xml exceptions
- Parallel dependency 5y old HOT 7
- Get Subscription Usage cost (monthly) HOT 8
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-armrest.