File: active_directory_service_settings.rb

package info (click to toggle)
ruby-ms-rest-azure 0.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 200 kB
  • sloc: ruby: 906; makefile: 4
file content (63 lines) | stat: -rw-r--r-- 2,217 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

module MsRestAzure
  #
  # Class which represents an settings for Azure AD authentication.
  #
  class ActiveDirectoryServiceSettings

    # @return [String] auth token.
    attr_accessor :authentication_endpoint

    # @return [String] auth token.
    attr_accessor :token_audience

    #
    # Returns a set of properties required to login into regular Azure cloud.
    #
    # @return [ActiveDirectoryServiceSettings] settings required for authentication.
    def self.get_azure_settings
      get_settings(MsRestAzure::AzureEnvironments::AzureCloud)
    end

    #
    # Returns a set of properties required to login into Azure China cloud.
    #
    # @return [ActiveDirectoryServiceSettings] settings required for authentication.
    def self.get_azure_china_settings
      get_settings(MsRestAzure::AzureEnvironments::AzureChinaCloud)
    end

    #
    # Returns a set of properties required to login into Azure German Cloud.
    #
    # @return [ActiveDirectoryServiceSettings] settings required for authentication.
    def self.get_azure_german_settings
      get_settings(MsRestAzure::AzureEnvironments::AzureGermanCloud)
    end

    #
    # Returns a set of properties required to login into Azure US Government.
    #
    # @return [ActiveDirectoryServiceSettings] settings required for authentication.
    def self.get_azure_us_government_settings
      get_settings(MsRestAzure::AzureEnvironments::AzureUSGovernment)
    end

    private

    #
    # Returns a set of properties required to login into Azure Cloud.
    #
    # @param azure_environment [AzureEnvironment] An instance of AzureEnvironment.
    # @return [ActiveDirectoryServiceSettings] settings required for authentication.
    def self.get_settings(azure_environment = MsRestAzure::AzureEnvironments::Azure)
      settings = ActiveDirectoryServiceSettings.new
      settings.authentication_endpoint = azure_environment.active_directory_endpoint_url
      settings.token_audience = azure_environment.active_directory_resource_id
      settings
    end
  end
end