-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take the pr from the deprecated omniauth-azure-oauth2
* Support for Oauth2 v2.0 marknadig/omniauth-azure-oauth2#29 * Make it work with this new gem
- Loading branch information
1 parent
310cc17
commit eaa7d69
Showing
9 changed files
with
403 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ | |
|
||
# rspec failure tracking | ||
.rspec_status | ||
|
||
# ide | ||
.idea |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require File.join('omniauth', 'strategies', 'azure_activedirectory_v2.rb') |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require 'omniauth-oauth2' | ||
|
||
module OmniAuth | ||
module Strategies | ||
class AzureActiveDirectoryV2 < OmniAuth::Strategies::OAuth2 | ||
BASE_AZURE_URL = 'https://login.microsoftonline.com' | ||
|
||
option :name, 'azure_activedirectory_v2' | ||
option :tenant_provider, nil | ||
|
||
DEFAULT_SCOPE = 'openid profile email' | ||
USER_INFO_URL = 'https://graph.microsoft.com/v1.0/me' | ||
|
||
# tenant_provider must return client_id, client_secret and optionally tenant_id and base_azure_url | ||
args [:tenant_provider] | ||
|
||
def client | ||
if options.tenant_provider | ||
provider = options.tenant_provider.new(self) | ||
else | ||
provider = options # if pass has to config, get mapped right on to options | ||
end | ||
|
||
options.client_id = provider.client_id | ||
options.client_secret = provider.client_secret | ||
options.tenant_id = | ||
provider.respond_to?(:tenant_id) ? provider.tenant_id : 'common' | ||
options.base_azure_url = | ||
provider.respond_to?(:base_azure_url) ? provider.base_azure_url : BASE_AZURE_URL | ||
|
||
options.authorize_params = provider.authorize_params if provider.respond_to?(:authorize_params) | ||
options.authorize_params.domain_hint = provider.domain_hint if provider.respond_to?(:domain_hint) && provider.domain_hint | ||
options.authorize_params.prompt = request.params['prompt'] if defined? request && request.params['prompt'] | ||
options.authorize_params.scope = (provider.scope if provider.respond_to?(:scope) && provider.scope) || DEFAULT_SCOPE | ||
|
||
options.client_options.authorize_url = "#{options.base_azure_url}/#{options.tenant_id}/oauth2/v2.0/authorize" | ||
options.client_options.token_url = "#{options.base_azure_url}/#{options.tenant_id}/oauth2/v2.0/token" | ||
|
||
super | ||
end | ||
|
||
uid { | ||
raw_info['id'] | ||
} | ||
|
||
info do | ||
{ | ||
name: raw_info['displayName'], | ||
first_name: raw_info['givenName'], | ||
last_name: raw_info['surname'], | ||
email: raw_info['userPrincipalName'], | ||
id: raw_info['id'], | ||
} | ||
end | ||
|
||
def callback_url | ||
full_host + script_name + callback_path | ||
end | ||
|
||
def raw_info | ||
@raw_info ||= access_token.get(USER_INFO_URL).parsed | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
require_relative 'lib/omniauth/azure/activedirectory/v2/version' | ||
require_relative 'lib/omniauth/azure_activedirectory_v2/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "omniauth-azure-activedirectory-v2" | ||
spec.version = Omniauth::Azure::Activedirectory::V2::VERSION | ||
spec.authors = ["Jesse Whitham"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.} | ||
spec.description = %q{TODO: Write a longer description or delete this line.} | ||
spec.homepage = "TODO: Put your gem's website or public repo URL here." | ||
spec.summary = %q{Write a short summary, because RubyGems requires one.} | ||
spec.description = %q{Write a longer description or delete this line.} | ||
spec.homepage = "https://github.com/RIPGlobal/omniauth-azure-activedirectory-v2" | ||
spec.license = "MIT" | ||
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") | ||
|
||
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." | ||
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
spec.metadata["source_code_uri"] = "https://github.com/RIPGlobal/omniauth-azure-activedirectory-v2" | ||
spec.metadata["changelog_uri"] = "https://github.com/RIPGlobal/omniauth-azure-activedirectory-v2" | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
|
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec| | |
spec.bindir = "exe" | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_dependency 'omniauth-oauth2' | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.