omniauth-office365 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +10 -0
- data/example/example.rb +29 -0
- data/lib/omniauth-office365.rb +1 -0
- data/lib/omniauth/office365.rb +2 -0
- data/lib/omniauth/office365/version.rb +5 -0
- data/lib/omniauth/strategies/office365.rb +39 -0
- data/omniauth-office365.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: a5cce7a1afcc580203fb7e67347d69535eb0fdbd
|
4
|
+
data.tar.gz: 1a76dba8a09f6b67b1bc635c1eda9c708988da00
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd022cee82bd5fc96c28a46293b9f7dc2d2591cc1ff024245fc052c4e5840dbdb7b46c068d5c7e8c4c3349f75161c3b9fbff9c428359910aed0653939426d29b
|
7
|
+
data.tar.gz: 9c92a19e2127532584c09c943c09e862275a4f45fcf8e96155be9a72873f0b26e8597e88d5c19436e181f043b953e2a0be426f79bfb4b1b2903d96267e16a6bd
|
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/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,36 @@
|
|
1
|
+
# Omniauth::Office365 [![Build Status](https://travis-ci.org/simi/omniauth-office365.svg?branch=master)](https://travis-ci.org/simi/omniauth-office365)
|
2
|
+
|
3
|
+
Office365 OAuth2 Strategy for OmniAuth.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-office365', github: 'simi/omniauth-office365'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install omniauth-office365
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
25
|
+
provider :office365, ENV['OFFICE365_KEY'], ENV['OFFICE365_SECRET']
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( https://github.com/simi/omniauth-office365/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
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-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/office365'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Office365 < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, :office365
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
site: 'https://outlook.office365.com/',
|
10
|
+
token_url: 'https://login.windows.net/common/oauth2/token',
|
11
|
+
authorize_url: 'https://login.windows.net/common/oauth2/authorize'
|
12
|
+
}
|
13
|
+
|
14
|
+
option :authorize_params, {
|
15
|
+
resource: 'https://graph.windows.net/'
|
16
|
+
}
|
17
|
+
|
18
|
+
uid { raw_info["objectId"] }
|
19
|
+
|
20
|
+
info do
|
21
|
+
{
|
22
|
+
'email' => raw_info["userPrincipalName"],
|
23
|
+
'name' => [raw_info["givenName"], raw_info["surname"]].join(' '),
|
24
|
+
'nickname' => raw_info["displayName"]
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
extra do
|
29
|
+
{
|
30
|
+
'raw_info' => raw_info
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def raw_info
|
35
|
+
@raw_info ||= access_token.get(authorize_params.resource + 'Me?api-version=1.5').parsed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
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/office365/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-office365"
|
8
|
+
spec.version = Omniauth::Office365::VERSION
|
9
|
+
spec.authors = ["Josef Šimánek"]
|
10
|
+
spec.email = ["josef.simanek@gmail.com"]
|
11
|
+
spec.summary = %q{omniauth provider for Office365}
|
12
|
+
spec.description = %q{omniauth provider for new Office365 API}
|
13
|
+
spec.homepage = "https://github.com/simi/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"
|
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/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,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-office365
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josef Šimánek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-25 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 Office365 API
|
84
|
+
email:
|
85
|
+
- josef.simanek@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .travis.yml
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- example/example.rb
|
97
|
+
- lib/omniauth-office365.rb
|
98
|
+
- lib/omniauth/office365.rb
|
99
|
+
- lib/omniauth/office365/version.rb
|
100
|
+
- lib/omniauth/strategies/office365.rb
|
101
|
+
- omniauth-office365.gemspec
|
102
|
+
- test/strategy_test.rb
|
103
|
+
- test/test_helper.rb
|
104
|
+
homepage: https://github.com/simi/omniauth-office365
|
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.2.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: omniauth provider for Office365
|
128
|
+
test_files:
|
129
|
+
- test/strategy_test.rb
|
130
|
+
- test/test_helper.rb
|