Class: Sitefull::Auth::Azure
- Inherits:
-
Base
- Object
- Base
- Sitefull::Auth::Azure
show all
- Defined in:
- lib/sitefull-cloud/auth/azure.rb
Constant Summary
collapse
- AUTHORIZATION_URI =
'https://login.microsoftonline.com/%s/oauth2/authorize'.freeze
- CALLBACK_URI =
'/oauth/azure/callback'.freeze
- SCOPE =
%w(https://management.core.windows.net/).freeze
- TOKEN_CREDENTIALS_URI =
'https://login.microsoftonline.com/%s/oauth2/token'.freeze
- MISSING_TENANT_ID =
'Missing Tenant ID'.freeze
Constants inherited
from Base
Base::MISSING_AUTHORIZATION_URI, Base::MISSING_BASE_URI, Base::MISSING_BASE_URI_SCHEME, Base::MISSING_CALLBACK_URI, Base::MISSING_CLIENT_ID, Base::MISSING_CLIENT_SECRET, Base::MISSING_REDIRECT_URI_SCHEME, Base::MISSING_SCOPE, Base::MISSING_TOKEN_CREDENTIALS_URI
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #token_options
Instance Method Details
#authorization_uri(options) ⇒ Object
36
37
38
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 36
def authorization_uri(options)
sprintf(AUTHORIZATION_URI, options[:tenant_id])
end
|
#authorization_url_options ⇒ Object
23
24
25
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 23
def authorization_url_options
super.merge({ resource: 'https://management.core.windows.net/'})
end
|
#callback_uri ⇒ Object
32
33
34
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 32
def callback_uri
CALLBACK_URI
end
|
#credentials(token) ⇒ Object
27
28
29
30
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 27
def credentials(token)
token_provider = MsRest::StringTokenProvider.new(token.access_token)
MsRest::TokenCredentials.new(token_provider)
end
|
#required_settings ⇒ Object
48
49
50
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 48
def required_settings
super << :tenant_id
end
|
#scope ⇒ Object
40
41
42
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 40
def scope
SCOPE
end
|
#token_credentials_uri(options) ⇒ Object
44
45
46
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 44
def token_credentials_uri(options)
sprintf(TOKEN_CREDENTIALS_URI, options[:tenant_id])
end
|
#validate(options = {}) ⇒ Object
18
19
20
21
|
# File 'lib/sitefull-cloud/auth/azure.rb', line 18
def validate(options = {})
fail MISSING_TENANT_ID if options[:tenant_id].nil? || options[:tenant_id].to_s.empty?
super(options)
end
|