omniauth-microsoft_graph 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of omniauth-microsoft_graph might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +10 -0
- data/example/example.rb +29 -0
- data/lib/microsoft_graph.rb +1 -0
- data/lib/omniauth/microsoft_graph.rb +2 -0
- data/lib/omniauth/microsoft_graph/version.rb +5 -0
- data/lib/omniauth/strategies/microsoft_graph.rb +46 -0
- data/omniauth-microsoft_graph.gemspec +27 -0
- data/test/strategy_test.rb +12 -0
- data/test/test_helper.rb +30 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 66a0ea4d256b036a576000cd3de91de39bfc45a0
|
4
|
+
data.tar.gz: ce2a59256d5db7b62f751a32b16e730bf1f940d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 969345446695fcceaded706cd2afbc5fb27ea9f1b63596d8942865cdaedbb63fd5ac9c23f6779c68ca7e5b0120e1bcf7949ac6e9f81c943d207934566de4e5bd
|
7
|
+
data.tar.gz: 92e18899eb92fac4f3249a0e4732ca378071a0564d0810ff0c180ce9a5abaa623038e256c96870fd6084a449e1ae7355b576979bdee539fb3f413c94d7231f50
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Josef Šimánek
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Omniauth::MicrosoftGraph [![Build Status](https://travis-ci.org/synth/omniauth-microsoft_graph.svg?branch=master)](https://travis-ci.org/synth/omniauth-microsoft_graph)
|
2
|
+
|
3
|
+
Microsoft Graph OAuth2 Strategy for OmniAuth.
|
4
|
+
Can be used to authenticate with Office365 or other MS services, and get a token for the Microsoft Graph Api, formerly the Office365 Unified Api.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'omniauth-microsoft_graph'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install omniauth-microsoft_graph
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
26
|
+
provider :microsoft_graph, ENV['AZURE_APPLICATION_CLIENT_ID'], ENV['AZURE_APPLICATION_CLIENT_SECRET']
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/synth/omniauth-microsoft_graph/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/example/example.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.push File.dirname(__FILE__) + '/../lib'
|
2
|
+
|
3
|
+
require 'omniauth-microsoft_graph'
|
4
|
+
require 'sinatra'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
set :port, 4200
|
8
|
+
|
9
|
+
client_id = ENV['AZURE_APPLICATION_CLIENT_ID']
|
10
|
+
secret = ENV['AZURE_APPLICATION_CLIENT_SECRET']
|
11
|
+
|
12
|
+
use Rack::Session::Cookie
|
13
|
+
use OmniAuth::Builder do
|
14
|
+
provider :microsoft_graph, client_id, secret
|
15
|
+
end
|
16
|
+
|
17
|
+
get '/' do
|
18
|
+
"<a href='/auth/microsoft_graph'>Log in with Microsoft</a>"
|
19
|
+
end
|
20
|
+
|
21
|
+
get '/auth/microsoft_graph/callback' do
|
22
|
+
content_type 'text/plain'
|
23
|
+
request.env['omniauth.auth'].to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
get '/auth/failure' do
|
27
|
+
content_type 'text/plain'
|
28
|
+
params.to_json
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/microsoft_graph'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class MicrosoftGraph < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, :microsoft_graph
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
site: 'https://login.microsoftonline.com/common/oauth2/authorize',
|
10
|
+
token_url: 'https://login.microsoftonline.com/common/oauth2/token',
|
11
|
+
authorize_url: 'https://login.microsoftonline.com/common/oauth2/authorize'
|
12
|
+
}
|
13
|
+
|
14
|
+
option :authorize_params, {
|
15
|
+
resource: 'https://graph.microsoft.com/'
|
16
|
+
}
|
17
|
+
|
18
|
+
option :token_params, {
|
19
|
+
resource: 'https://graph.microsoft.com/'
|
20
|
+
}
|
21
|
+
|
22
|
+
uid { raw_info["id"] }
|
23
|
+
|
24
|
+
info do
|
25
|
+
{
|
26
|
+
'email' => raw_info["mail"],
|
27
|
+
'first_name' => raw_info["givenName"],
|
28
|
+
'last_name' => raw_info["surname"],
|
29
|
+
'name' => [raw_info["givenName"], raw_info["surname"]].join(' '),
|
30
|
+
'nickname' => raw_info["displayName"],
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
extra do
|
35
|
+
{
|
36
|
+
'raw_info' => raw_info,
|
37
|
+
'params' => access_token.params
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def raw_info
|
42
|
+
@raw_info ||= access_token.get(authorize_params.resource + 'v1.0/me').parsed
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/microsoft_graph/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-microsoft_graph"
|
8
|
+
spec.version = Omniauth::Office365::VERSION
|
9
|
+
spec.authors = ["Peter Philips"]
|
10
|
+
spec.email = ["pete@p373.net"]
|
11
|
+
spec.summary = %q{omniauth provider for Microsoft Graph}
|
12
|
+
spec.description = %q{omniauth provider for new Microsoft Graph API}
|
13
|
+
spec.homepage = "https://github.com/synth/omniauth-microsoft_graph"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "omniauth-oauth2"
|
22
|
+
|
23
|
+
spec.add_development_dependency "sinatra"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "minitest"
|
26
|
+
spec.add_development_dependency "mocha"
|
27
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'omniauth/strategies/microsoft_graph'
|
5
|
+
|
6
|
+
OmniAuth.config.test_mode = true
|
7
|
+
|
8
|
+
class StrategyTestCase < Minitest::Test
|
9
|
+
def setup
|
10
|
+
@request = stub('Request')
|
11
|
+
@request.stubs(:params).returns({})
|
12
|
+
@request.stubs(:cookies).returns({})
|
13
|
+
@request.stubs(:env).returns({})
|
14
|
+
@request.stubs(:scheme).returns({})
|
15
|
+
@request.stubs(:ssl?).returns(false)
|
16
|
+
|
17
|
+
@client_id = '123'
|
18
|
+
@client_secret = '53cr3tz'
|
19
|
+
end
|
20
|
+
|
21
|
+
def strategy
|
22
|
+
@strategy ||= begin
|
23
|
+
args = [@client_id, @client_secret, @options].compact
|
24
|
+
OmniAuth::Strategies::MicrosoftGraph.new(nil, *args).tap do |strategy|
|
25
|
+
strategy.stubs(:request).returns(@request)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-microsoft_graph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Philips
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sinatra
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: omniauth provider for new Microsoft Graph API
|
84
|
+
email:
|
85
|
+
- pete@p373.net
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".travis.yml"
|
91
|
+
- CHANGELOG.md
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- example/example.rb
|
97
|
+
- lib/microsoft_graph.rb
|
98
|
+
- lib/omniauth/microsoft_graph.rb
|
99
|
+
- lib/omniauth/microsoft_graph/version.rb
|
100
|
+
- lib/omniauth/strategies/microsoft_graph.rb
|
101
|
+
- omniauth-microsoft_graph.gemspec
|
102
|
+
- test/strategy_test.rb
|
103
|
+
- test/test_helper.rb
|
104
|
+
homepage: https://github.com/synth/omniauth-microsoft_graph
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.8
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: omniauth provider for Microsoft Graph
|
128
|
+
test_files:
|
129
|
+
- test/strategy_test.rb
|
130
|
+
- test/test_helper.rb
|