omniauth-ms-office365 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/example/example.rb +29 -0
- data/lib/omniauth-ms-office365.rb +1 -0
- data/lib/omniauth/ms_office365.rb +2 -0
- data/lib/omniauth/ms_office365/version.rb +5 -0
- data/lib/omniauth/strategies/ms_office365.rb +40 -0
- data/omniauth-ms-office365.gemspec +27 -0
- data/test/strategy_test.rb +12 -0
- data/test/test_helper.rb +30 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14bb8ec08bb74d11f7013b479eb577083585c4b4977878b33b609a5d57e48eba
|
4
|
+
data.tar.gz: 2fd0390330f3a59991b42236c2c6914296bbd90ef9cc02473d9b3432ad495381
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d2f60427d878192622e06ae7ddd1fd14071f43b35a0a342e7aea476abaaa3aaf7b224c5cbdfff8d5b4fae1ac151d1246b6ef68e422dbec6bedcd2f202fcce4eb
|
7
|
+
data.tar.gz: 6177dc8de177e060bcae742024840d4835ad5c59884f35562d5104b1547f34b9cc3edd770a9eea85294e84e98ece9b01fae5ad237bc3e70b142c55c30034e767
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Suhas Nehete, Josef Šimánek
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Omniauth::Office365
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/omniauth-office365)
|
4
|
+
[](https://travis-ci.org/simi/omniauth-office365)
|
5
|
+
[](https://codeclimate.com/github/suhaspan/omniauth-office365)
|
6
|
+
|
7
|
+
Microsoft Office365 v2.0 OmniAuth OAuth2 Strategy - https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'omniauth-office365'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install omniauth-office365
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
29
|
+
provider :office365, ENV['OFFICE365_KEY'], ENV['OFFICE365_SECRET']
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## Reference Links
|
34
|
+
Microsoft Office365 v2.0 - https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
35
|
+
|
36
|
+
Scopes and Resource - https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent
|
37
|
+
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome.
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b new-feature`)
|
45
|
+
3. Commit your changes along with test cases (`git commit -m 'Add feature'`)
|
46
|
+
4. If possible squash your commits to one commit if they all belong to same feature.
|
47
|
+
5. Push to the branch (`git push origin new-feature`)
|
48
|
+
6. Create new Pull Request.
|
49
|
+
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/example/example.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.push File.dirname(__FILE__) + '/../lib'
|
2
|
+
|
3
|
+
require 'omniauth-ms-office365'
|
4
|
+
require 'sinatra'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
set :port, 4200
|
8
|
+
|
9
|
+
office365_client_id = ENV['OFFICE365_CLIENT_ID']
|
10
|
+
office365_client_secret = ENV['OFFICE365_CLIENT_SECRET']
|
11
|
+
|
12
|
+
use Rack::Session::Cookie
|
13
|
+
use OmniAuth::Builder do
|
14
|
+
provider :office365, office365_client_id, office365_client_secret
|
15
|
+
end
|
16
|
+
|
17
|
+
get '/' do
|
18
|
+
"<a href='/auth/office365'>Log in with Office365</a>"
|
19
|
+
end
|
20
|
+
|
21
|
+
get '/auth/office365/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/ms_office365'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class MsOffice365 < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, :office365
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
site: 'https://login.microsoftonline.com',
|
10
|
+
authorize_url: '/common/oauth2/v2.0/authorize',
|
11
|
+
token_url: '/common/oauth2/v2.0/token'
|
12
|
+
}
|
13
|
+
|
14
|
+
def authorize_params
|
15
|
+
options.authorize_params[:scope] = 'offline_access openid User.Read Contacts.Read'
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
uid { raw_info['id'] }
|
20
|
+
|
21
|
+
info do
|
22
|
+
{
|
23
|
+
'email' => raw_info["userPrincipalName"],
|
24
|
+
'name' => [raw_info["givenName"], raw_info["surname"]].join(' '),
|
25
|
+
'nickname' => raw_info["displayName"]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
extra do
|
30
|
+
{
|
31
|
+
'raw_info' => raw_info
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def raw_info
|
36
|
+
@raw_info ||= access_token.get('https://graph.microsoft.com/v1.0/me').parsed
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
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/ms_office365/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-ms-office365"
|
8
|
+
spec.version = Omniauth::MsOffice365::VERSION
|
9
|
+
spec.authors = ['Suhas Nehete', 'Josef Šimánek']
|
10
|
+
spec.email = ['suhas0284@gmail.com', 'josef.simanek@gmail.com']
|
11
|
+
spec.summary = %q{Microsoft Office365 v2.0 OmniAuth OAuth2 Provider}
|
12
|
+
spec.description = %q{Microsoft Office365 v2.0 OmniAuth OAuth2 Provider. Create an account and generate client_id and client_secret.}
|
13
|
+
spec.homepage = "https://github.com/suhaspan/omniauth-office365"
|
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", '~> 1.3'
|
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/ms_office365'
|
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::Office365.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,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-ms-office365
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Suhas Nehete
|
8
|
+
- Josef Šimánek
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-09-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: sinatra
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: mocha
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description: Microsoft Office365 v2.0 OmniAuth OAuth2 Provider. Create an account
|
85
|
+
and generate client_id and client_secret.
|
86
|
+
email:
|
87
|
+
- suhas0284@gmail.com
|
88
|
+
- josef.simanek@gmail.com
|
89
|
+
executables: []
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- example/example.rb
|
101
|
+
- lib/omniauth-ms-office365.rb
|
102
|
+
- lib/omniauth/ms_office365.rb
|
103
|
+
- lib/omniauth/ms_office365/version.rb
|
104
|
+
- lib/omniauth/strategies/ms_office365.rb
|
105
|
+
- omniauth-ms-office365.gemspec
|
106
|
+
- test/strategy_test.rb
|
107
|
+
- test/test_helper.rb
|
108
|
+
homepage: https://github.com/suhaspan/omniauth-office365
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.7.6.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Microsoft Office365 v2.0 OmniAuth OAuth2 Provider
|
132
|
+
test_files:
|
133
|
+
- test/strategy_test.rb
|
134
|
+
- test/test_helper.rb
|