omniauth-microsoft-office365 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 53b562507262bff31f9e0812ca08aeac2ac8a58e
4
+ data.tar.gz: bb2d88a302096095784c0d2eedc26b5502f39d9a
5
+ SHA512:
6
+ metadata.gz: 9c3e46a094914b989128daf8476dae6ee4f44ea5bf2729a7163d0904d5adc24553d70a3b0457e8da215bcf62114288adb6c88e511572ac5b05ce8ac40e820b6e
7
+ data.tar.gz: fba7109c763f7a89d8548a948d3ac852609a8a0397739103134c86ff2894d9613ae86a82bd00e4e93e9161424bc1d44cf9212d2e91dc3e36729ceb4a0dffa33a
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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ omniauth-microsoft-office365-development
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.0-preview1
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-microsoft-office365.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Marcin Urbański
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,27 @@
1
+ # Omniauth::Microsoft::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-microsoft-office365'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-microsoft-office365
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :microsoft_office365, ENV['OFFICE365_KEY'], ENV['OFFICE365_SECRET']
26
+ end
27
+ ```
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module MicrosoftOffice365
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ require "omniauth/strategies/oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class MicrosoftOffice365 < OmniAuth::Strategies::OAuth2
6
+ option :name, :microsoft_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
+ option :authorize_params, {
15
+ scope: "openid email profile https://outlook.office.com/contacts.read",
16
+ }
17
+
18
+ uid { raw_info["Id"] }
19
+
20
+ info do
21
+ {
22
+ email: raw_info["EmailAddress"],
23
+ display_name: raw_info["DisplayName"],
24
+ first_name: raw_info["DisplayName"].split(", ")[1],
25
+ last_name: raw_info["DisplayName"].split(", ")[0],
26
+ alias: raw_info["Alias"]
27
+ }
28
+ end
29
+
30
+ extra do
31
+ {
32
+ "raw_info" => raw_info
33
+ }
34
+ end
35
+
36
+ def raw_info
37
+ @raw_info ||= access_token.get("https://outlook.office.com/api/v2.0/me/").parsed
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/microsoft_office365/version"
2
+ require "omniauth/strategies/microsoft_office365"
@@ -0,0 +1,30 @@
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_office365/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-microsoft-office365"
8
+ spec.version = Omniauth::MicrosoftOffice365::VERSION
9
+ spec.authors = ["Marcin Urbański"]
10
+ spec.email = ["marcin@urbanski.vdl.pl"]
11
+ spec.summary = %q{Omniauth provider for Microsoft Office365}
12
+ spec.description = %q{Omniauth provider for Microsoft Office365}
13
+ spec.homepage = "https://github.com/murbanski/omniauth-microsoft-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.required_ruby_version = '>= 2.1'
22
+
23
+ spec.add_runtime_dependency "omniauth"
24
+ spec.add_runtime_dependency "omniauth-oauth2"
25
+
26
+ spec.add_development_dependency "bundler", ">= 1.6"
27
+ spec.add_development_dependency "rake", ">= 11.1.2"
28
+ spec.add_development_dependency "rspec", ">= 3.4.0"
29
+ spec.add_development_dependency "pry", ">= 0.10.3"
30
+ end
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe OmniAuth::Strategies::MicrosoftOffice365 do
4
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
5
+ let(:options) { { } }
6
+
7
+ let(:app) do
8
+ lambda do
9
+ [200, {}, ["Hello."]]
10
+ end
11
+ end
12
+
13
+ let(:strategy) do
14
+ OmniAuth::Strategies::MicrosoftOffice365.new(app, 'appid', 'secret', options)
15
+ end
16
+
17
+ before do
18
+ OmniAuth.config.test_mode = true
19
+ allow(strategy).to receive(:request).and_return(request)
20
+ end
21
+
22
+ after do
23
+ OmniAuth.config.test_mode = false
24
+ end
25
+
26
+ describe "#name" do
27
+ it "returns :microsoft_office365" do
28
+ expect(strategy.name).to eq(:microsoft_office365)
29
+ end
30
+ end
31
+
32
+ describe "#client_options" do
33
+ context "with defaults" do
34
+ it "uses correct site" do
35
+ expect(strategy.client.site).to eq("https://login.microsoftonline.com")
36
+ end
37
+
38
+ it "uses correct authorize_url" do
39
+ expect(strategy.client.authorize_url).to eq("https://login.microsoftonline.com/common/oauth2/v2.0/authorize")
40
+ end
41
+
42
+ it "uses correct token_url" do
43
+ expect(strategy.client.token_url).to eq("https://login.microsoftonline.com/common/oauth2/v2.0/token")
44
+ end
45
+ end
46
+
47
+ context "with customized client options" do
48
+ let(:options) do
49
+ {
50
+ client_options: {
51
+ 'site' => 'https://example.com',
52
+ 'authorize_url' => 'https://example.com/authorize',
53
+ 'token_url' => 'https://example.com/token',
54
+ }
55
+ }
56
+ end
57
+
58
+ it "uses customized site" do
59
+ expect(strategy.client.site).to eq("https://example.com")
60
+ end
61
+
62
+ it "uses customized authorize_url" do
63
+ expect(strategy.client.authorize_url).to eq("https://example.com/authorize")
64
+ end
65
+
66
+ it "uses customized token_url" do
67
+ expect(strategy.client.token_url).to eq("https://example.com/token")
68
+ end
69
+ end
70
+ end
71
+
72
+ describe "#authorize_params" do
73
+ let(:options) do
74
+ { authorize_params: { foo: "bar", baz: "zip" } }
75
+ end
76
+
77
+ it "uses correct scope and allows to customize authorization parameters" do
78
+ expect(strategy.authorize_params).to match(
79
+ "scope" => "openid email profile https://outlook.office.com/contacts.read",
80
+ "foo" => "bar",
81
+ "baz" => "zip",
82
+ "state" => /\A\h{48}\z/
83
+ )
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pry"
3
+ require 'omniauth-microsoft-office365'
4
+
5
+ RSpec.configure do |config|
6
+ config.mock_with :rspec do |mocks|
7
+ mocks.verify_partial_doubles = true
8
+ end
9
+
10
+ config.disable_monkey_patching!
11
+ config.expose_dsl_globally = false
12
+ config.profile_examples = 3
13
+ config.order = :random
14
+ Kernel.srand config.seed
15
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-microsoft-office365
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marcin Urbański
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
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: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 11.1.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 11.1.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.4.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.3
97
+ description: Omniauth provider for Microsoft Office365
98
+ email:
99
+ - marcin@urbanski.vdl.pl
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".ruby-gemset"
107
+ - ".ruby-version"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - lib/omniauth-microsoft-office365.rb
114
+ - lib/omniauth/microsoft_office365/version.rb
115
+ - lib/omniauth/strategies/microsoft_office365.rb
116
+ - omniauth-microsoft-office365.gemspec
117
+ - spec/omniauth/strategies/microsoft_office365_spec.rb
118
+ - spec/spec_helper.rb
119
+ homepage: https://github.com/murbanski/omniauth-microsoft-office365
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '2.1'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.5.0
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Omniauth provider for Microsoft Office365
143
+ test_files:
144
+ - spec/omniauth/strategies/microsoft_office365_spec.rb
145
+ - spec/spec_helper.rb