Class: Kitchen::Driver::Azure::ServicePrincipalToken
- Inherits:
-
TokenProvider
- Object
- TokenProvider
- Kitchen::Driver::Azure::ServicePrincipalToken
- Defined in:
- lib/kitchen/driver/azure/token_provider.rb
Overview
Authenticates as a service principal, using a client id and secret.
Constant Summary
Constants inherited from TokenProvider
Instance Attribute Summary
Attributes inherited from TokenProvider
Instance Method Summary collapse
- #fetch_token ⇒ Array(String, Integer)
-
#initialize(environment:, tenant_id:, client_id:, client_secret:) ⇒ ServicePrincipalToken
constructor
A new instance of ServicePrincipalToken.
Methods inherited from TokenProvider
#access_token, #authorization_header
Constructor Details
#initialize(environment:, tenant_id:, client_id:, client_secret:) ⇒ ServicePrincipalToken
Returns a new instance of ServicePrincipalToken.
98 99 100 101 102 103 |
# File 'lib/kitchen/driver/azure/token_provider.rb', line 98 def initialize(environment:, tenant_id:, client_id:, client_secret:) super(environment:) @tenant_id = tenant_id @client_id = client_id @client_secret = client_secret end |
Instance Method Details
#fetch_token ⇒ Array(String, Integer)
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/kitchen/driver/azure/token_provider.rb', line 106 def fetch_token response = Http.request( method: :post, url: environment.token_url(@tenant_id), headers: { "Content-Type" => "application/x-www-form-urlencoded" }, body: URI.encode_www_form( grant_type: "client_credentials", client_id: @client_id, client_secret: @client_secret, resource: environment.token_audience ) ) token_from(response, "the service principal token endpoint") end |