omniauth-chef 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0bbedb2dab18096a3380d45c56397dbe02ede3db
4
+ data.tar.gz: 6e47f5491a174804b08a648adbc574570a4a4b33
5
+ SHA512:
6
+ metadata.gz: b03505fa1200a3279e091ec2d2521fb5178f3c54cc31286523ee8f279c765f4afb1f27c2ca6a859c36edcd07c8476df61cf3f4fe2d4e56ae7218592d843bfbff
7
+ data.tar.gz: 518fc063878b8ef59403e201ba068a81926bc81d57772b56638262edc78ff1ba3d0547f25bb4a1a2ab3c81938f1b3004a845f57312b4d4575c0e4f912a544c89
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ task default: :spec
@@ -0,0 +1,20 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'omniauth-chef/version'
19
+
20
+ require 'omniauth/strategies/chef'
@@ -0,0 +1,22 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module OmniAuth
19
+ module Chef
20
+ VERSION = '0.1.0'
21
+ end
22
+ end
@@ -0,0 +1,110 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef'
19
+ require 'omniauth'
20
+
21
+ module OmniAuth
22
+ module Strategies
23
+ class Chef
24
+ include OmniAuth::Strategy
25
+
26
+ option :endpoint, 'https://api.opscode.piab'
27
+ option :fields, [:name, :password]
28
+ option :headers, { }
29
+ option :organization, nil
30
+ option :resource, 'authenticate_user'
31
+ option :source, 'web'
32
+ option :superuser, 'pivotal'
33
+ option :key_path, '../../../../config/webui_priv.pem'
34
+ option :uid, :name
35
+
36
+ def callback_phase
37
+ @user = authenticated_user
38
+
39
+ authenticated? ? super : fail!(:invalid_credentials)
40
+ end
41
+
42
+ uid do
43
+ @user['username']
44
+ end
45
+
46
+ info do
47
+ {
48
+ email: @user['email'],
49
+ first_name: @user['first_name'],
50
+ last_name: @user['last_name'],
51
+ name: @user['display_name']
52
+ }
53
+ end
54
+
55
+ extra do
56
+ { raw_info: @user }
57
+ end
58
+
59
+ protected
60
+
61
+ def authenticated_user
62
+ begin
63
+ chef.post_rest(resource, username: username, password: password)['user']
64
+ rescue Net::HTTPServerException
65
+
66
+ end
67
+ end
68
+
69
+ def authenticated?
70
+ @user ? true : false
71
+ end
72
+
73
+ def chef
74
+ ::Chef::REST.new endpoint, options.superuser, nil, parameters
75
+ end
76
+
77
+ def endpoint
78
+ organization ? "#{options.endpoint}/#{organization}" : options.endpoint
79
+ end
80
+
81
+ def headers
82
+ options.headers.merge({ 'x-ops-request-source' => options.source })
83
+ end
84
+
85
+ def key
86
+ IO.read(File.expand_path(options.key_path, __FILE__)).strip
87
+ end
88
+
89
+ def organization
90
+ options.organization
91
+ end
92
+
93
+ def parameters
94
+ { headers: headers, raw_key: key }
95
+ end
96
+
97
+ def password
98
+ options.password ? options.password : request[:password]
99
+ end
100
+
101
+ def resource
102
+ options.resource
103
+ end
104
+
105
+ def username
106
+ options.username ? options.username : request[:username]
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path '../lib', __FILE__
4
+
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include? lib
6
+
7
+ require 'omniauth-chef/version'
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = 'omniauth-chef'
11
+ spec.version = OmniAuth::Chef::VERSION
12
+ spec.authors = ['Allen Goodman']
13
+ spec.email = %q(a@getchef.com)
14
+ spec.description = %q{OmniAuth strategy for Chef}
15
+ spec.summary = %q{OmniAuth strategy for Chef}
16
+ spec.homepage = 'https://github.com/opscode/oc_actionlog'
17
+ spec.license = 'Apache-2.0'
18
+
19
+ spec.files = %w(.gitignore omniauth-chef.gemspec Gemfile Rakefile)
20
+ spec.files += Dir.glob 'lib/**/*.rb'
21
+ spec.files += Dir.glob 'bin/**/*'
22
+
23
+ spec.test_files = Dir.glob 'spec/**/*.rb'
24
+
25
+ spec.require_paths = Dir.glob 'lib/**/*.rb'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.5'
28
+ spec.add_development_dependency 'rack-test', '~> 0'
29
+ spec.add_development_dependency 'rake', '~> 10'
30
+ spec.add_development_dependency 'rspec', '~> 2'
31
+
32
+ spec.add_runtime_dependency 'chef', '~> 11'
33
+ spec.add_runtime_dependency 'omniauth', '~> 1.2'
34
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ describe OmniAuth::Strategies::Chef do
22
+
23
+ end
@@ -0,0 +1,37 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ $:.unshift File.expand_path '..', __FILE__
19
+
20
+ $:.unshift File.expand_path '../../lib', __FILE__
21
+
22
+ require 'omniauth'
23
+ require 'omniauth-chef'
24
+
25
+ require 'rack/test'
26
+
27
+ require 'rspec'
28
+
29
+ RSpec.configure do |configuration|
30
+ configuration.extend OmniAuth::Test::StrategyMacros, type: :strategy
31
+
32
+ configuration.include Rack::Test::Methods
33
+
34
+ configuration.expect_with :rspec do |rspec_configuration|
35
+ rspec_configuration.syntax = :expect
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-chef
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Allen Goodman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-test
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: '10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: chef
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '11'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: omniauth
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ description: OmniAuth strategy for Chef
98
+ email: a@getchef.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - ".gitignore"
104
+ - Gemfile
105
+ - Rakefile
106
+ - lib/omniauth-chef.rb
107
+ - lib/omniauth-chef/version.rb
108
+ - lib/omniauth/strategies/chef.rb
109
+ - omniauth-chef.gemspec
110
+ - spec/omniauth/strategies/chef_spec.rb
111
+ - spec/spec_helper.rb
112
+ homepage: https://github.com/opscode/oc_actionlog
113
+ licenses:
114
+ - Apache-2.0
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib/omniauth/strategies/chef.rb
120
+ - lib/omniauth-chef/version.rb
121
+ - lib/omniauth-chef.rb
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.2.0
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: OmniAuth strategy for Chef
138
+ test_files:
139
+ - spec/omniauth/strategies/chef_spec.rb
140
+ - spec/spec_helper.rb