omniauth-inspur 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 +35 -0
- data/.project +18 -0
- data/.rspec +1 -0
- data/Dockerfile +28 -0
- data/Gemfile +4 -0
- data/Makefile +6 -0
- data/README.md +43 -0
- data/Rakefile +7 -0
- data/lib/omniauth-inspur.rb +2 -0
- data/lib/omniauth-inspur/version.rb +5 -0
- data/lib/omniauth/strategies/inspur.rb +53 -0
- data/omniauth-inspur.gemspec +26 -0
- data/spec/omniauth/strategies/inspur_spec.rb +58 -0
- data/spec/spec_helper.rb +8 -0
- metadata +143 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 76bbd592aace04b5e893d06cbcf2f29a0c587d35aec343ecb2fffeec34a675e3
|
|
4
|
+
data.tar.gz: 7a28c37d5f53ea31cf8627090c64dc03ad1be27586afd3018ff70378742ee258
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4923d52e0215784d2f0b0c87def3c72f583ee22eb6bcd7cbdb6e8c9896794b47d1a406f69f36f603f8d4fc24887f6c9730c3906a9974bba17f92ac692bf66568
|
|
7
|
+
data.tar.gz: 3603d99a8dc31734cb9523e05c4cadd53c6410864e6ee185a63c8d9925cea18faf9e0a9b8ab7b692f1bde6c0b18a6031f7d6b4b1cf46d9899843205ed4a09845
|
data/.gitignore
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
.rvmrc
|
|
7
|
+
Gemfile.lock
|
|
8
|
+
InstalledFiles
|
|
9
|
+
_yardoc
|
|
10
|
+
coverage
|
|
11
|
+
doc/
|
|
12
|
+
lib/bundler/man
|
|
13
|
+
pkg
|
|
14
|
+
rdoc
|
|
15
|
+
spec/reports
|
|
16
|
+
test/tmp
|
|
17
|
+
test/version_tmp
|
|
18
|
+
tmp
|
|
19
|
+
### IntelliJ IDEA ###
|
|
20
|
+
.idea
|
|
21
|
+
*.iws
|
|
22
|
+
*.iml
|
|
23
|
+
*.ipr
|
|
24
|
+
|
|
25
|
+
### NetBeans ###
|
|
26
|
+
/nbproject/private/
|
|
27
|
+
/nbbuild/
|
|
28
|
+
/dist/
|
|
29
|
+
/nbdist/
|
|
30
|
+
/.nb-gradle/
|
|
31
|
+
build/
|
|
32
|
+
|
|
33
|
+
### VS Code ###
|
|
34
|
+
.vscode/
|
|
35
|
+
/zeppelin/
|
data/.project
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name>omniauth-inspur</name>
|
|
4
|
+
<comment></comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>com.aptana.ide.core.unifiedBuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
</buildSpec>
|
|
14
|
+
<natures>
|
|
15
|
+
<nature>com.aptana.ruby.core.rubynature</nature>
|
|
16
|
+
<nature>com.aptana.projects.webnature</nature>
|
|
17
|
+
</natures>
|
|
18
|
+
</projectDescription>
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--colour
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#####################
|
|
2
|
+
# Building Stage #
|
|
3
|
+
#####################
|
|
4
|
+
FROM ruby:2.7-alpine as builder
|
|
5
|
+
|
|
6
|
+
RUN gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ && \
|
|
7
|
+
gem sources -l && \
|
|
8
|
+
git clone https://github.com/YuanZhencai/omniauth-inspur.git && \
|
|
9
|
+
cd omniauth-inspur && \
|
|
10
|
+
ls -al && \
|
|
11
|
+
gem build omniauth-inspur.gemspec
|
|
12
|
+
|
|
13
|
+
######################
|
|
14
|
+
# Production Stage #
|
|
15
|
+
######################
|
|
16
|
+
|
|
17
|
+
FROM registry.cn-hangzhou.aliyuncs.com/palan/gitlab-zh:11.1.4 as production
|
|
18
|
+
LABEL maintainer="Yuan <zhencai.yuan@datarx.cn>"
|
|
19
|
+
|
|
20
|
+
COPY --from=builder /omniauth-inspur/omniauth-inspur-1.0.0.gem /omniauth-inspur-1.0.0.gem
|
|
21
|
+
|
|
22
|
+
RUN ls -al / && \
|
|
23
|
+
gem install /omniauth-inspur-1.0.0.gem --local && \
|
|
24
|
+
rm -rf /omniauth-inspur-1.0.0.gem && \
|
|
25
|
+
cd /opt/gitlab/embedded/service/gitlab-rails && \
|
|
26
|
+
echo "gem 'omniauth-inspur', '~> 1.0.0'" >> Gemfile && \
|
|
27
|
+
bundle install --local && \
|
|
28
|
+
bundle info omniauth-inspur
|
data/Gemfile
ADDED
data/Makefile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Omniauth::Inspur
|
|
2
|
+
|
|
3
|
+
This is the OAuth2 strategy for authenticating to your Inspur service.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'omniauth-inspur'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem build omniauth-inspur.gemspec
|
|
18
|
+
$ gem install omniauth-inspur
|
|
19
|
+
|
|
20
|
+
## Basic Usage
|
|
21
|
+
|
|
22
|
+
use OmniAuth::Builder do
|
|
23
|
+
provider :inspur, ENV['INSPUR_KEY'], ENV['INSPUR_SECRET']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
## Standalone Usage
|
|
27
|
+
|
|
28
|
+
use OmniAuth::Builder do
|
|
29
|
+
provider :inspur, ENV['INSPUR_KEY'], ENV['INSPUR_SECRET'],
|
|
30
|
+
{
|
|
31
|
+
client_options: {
|
|
32
|
+
site: 'https://inspur.com'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
## Contributing
|
|
38
|
+
|
|
39
|
+
1. Fork it
|
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
require 'omniauth-oauth2'
|
|
3
|
+
|
|
4
|
+
module OmniAuth
|
|
5
|
+
module Strategies
|
|
6
|
+
class Inspur < OmniAuth::Strategies::OAuth2
|
|
7
|
+
option :name, 'inspur'
|
|
8
|
+
|
|
9
|
+
option :client_options, {
|
|
10
|
+
site: 'https://inspur.com',
|
|
11
|
+
authorize_url: '/oauth/authorize',
|
|
12
|
+
token_url: '/oauth/token',
|
|
13
|
+
user_info_url: '/admin/system/user/getUserInfo',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
option :redirect_url
|
|
17
|
+
|
|
18
|
+
uid { raw_info['userId'].to_s }
|
|
19
|
+
|
|
20
|
+
info do
|
|
21
|
+
{
|
|
22
|
+
name: raw_info['userName'],
|
|
23
|
+
username: raw_info['loginName'],
|
|
24
|
+
email: raw_info['email']
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
extra do
|
|
29
|
+
{ raw_info: raw_info }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def raw_info
|
|
33
|
+
@raw_info ||= access_token.get(option.client_options.user_info_url,
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-type': 'application/json',
|
|
36
|
+
'token': "#{access_token.token}",
|
|
37
|
+
}).parsed
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def email
|
|
41
|
+
(raw_info['email']) ? raw_info['email'] : "#{raw_info['loginName']}@indata.com"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def callback_url
|
|
47
|
+
options.redirect_url || (full_host + script_name + callback_path)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
OmniAuth.config.add_camelization 'inspur', 'Inspur'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'omniauth-inspur/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = 'omniauth-inspur'
|
|
8
|
+
gem.version = Omniauth::Inspur::VERSION
|
|
9
|
+
gem.authors = ['YuanZhencai']
|
|
10
|
+
gem.email = ['zhencai.yuan@datarx.cn']
|
|
11
|
+
gem.description = 'This is the strategy for authenticating to your Inspur service'
|
|
12
|
+
gem.summary = 'This is the strategy for authenticating to your Inspur service'
|
|
13
|
+
gem.homepage = 'https://github.com/YuanZhencai/omniauth-inspur'
|
|
14
|
+
|
|
15
|
+
gem.files = `git ls-files`.split($/)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
gem.require_paths = ['lib']
|
|
19
|
+
|
|
20
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
|
21
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.0'
|
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3.1'
|
|
23
|
+
gem.add_development_dependency 'rspec-its', '~> 1.0'
|
|
24
|
+
gem.add_development_dependency 'simplecov'
|
|
25
|
+
gem.add_development_dependency 'rake', '>= 12.0'
|
|
26
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe OmniAuth::Strategies::Inspur do
|
|
4
|
+
let(:access_token) { double('AccessToken') }
|
|
5
|
+
let(:parsed_response) { double('ParsedResponse') }
|
|
6
|
+
let(:response) { double('Response', parsed: parsed_response) }
|
|
7
|
+
|
|
8
|
+
let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
|
|
9
|
+
|
|
10
|
+
let(:inspur_service) { OmniAuth::Strategies::Inspur.new({}) }
|
|
11
|
+
let(:enterprise) do
|
|
12
|
+
OmniAuth::Strategies::Inspur.new(
|
|
13
|
+
'INSPUR_KEY',
|
|
14
|
+
'INSPUR_SECRET',
|
|
15
|
+
client_options: { site: enterprise_site },
|
|
16
|
+
redirect_url: 'http://localhost:9292/callback_url'
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
subject { inspur_service }
|
|
21
|
+
|
|
22
|
+
before(:each) do
|
|
23
|
+
allow(subject).to receive(:access_token).and_return(access_token)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe 'client options' do
|
|
27
|
+
context 'with defaults' do
|
|
28
|
+
subject { inspur_service.options.client_options }
|
|
29
|
+
|
|
30
|
+
its(:site) { is_expected.to eq 'https://inspur.com/api/v4' }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'with override' do
|
|
34
|
+
subject { enterprise.options.client_options }
|
|
35
|
+
|
|
36
|
+
its(:site) { is_expected.to eq enterprise_site }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe 'redirect_url' do
|
|
41
|
+
context 'with defaults' do
|
|
42
|
+
subject { inspur_service.options }
|
|
43
|
+
its(:redirect_url) { is_expected.to be_nil }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context 'with customs' do
|
|
47
|
+
subject { enterprise.options }
|
|
48
|
+
its(:redirect_url) { is_expected.to eq 'http://localhost:9292/callback_url' }
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '#raw_info' do
|
|
53
|
+
it 'sent request to current user endpoint' do
|
|
54
|
+
expect(access_token).to receive(:get).with('user').and_return(response)
|
|
55
|
+
expect(subject.raw_info).to eq(parsed_response)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: omniauth-inspur
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- YuanZhencai
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-08-19 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: '1.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.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: '1.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.1'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.1'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec-its
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: simplecov
|
|
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
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rake
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '12.0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '12.0'
|
|
97
|
+
description: This is the strategy for authenticating to your Inspur service
|
|
98
|
+
email:
|
|
99
|
+
- zhencai.yuan@datarx.cn
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".project"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- Dockerfile
|
|
108
|
+
- Gemfile
|
|
109
|
+
- Makefile
|
|
110
|
+
- README.md
|
|
111
|
+
- Rakefile
|
|
112
|
+
- lib/omniauth-inspur.rb
|
|
113
|
+
- lib/omniauth-inspur/version.rb
|
|
114
|
+
- lib/omniauth/strategies/inspur.rb
|
|
115
|
+
- omniauth-inspur.gemspec
|
|
116
|
+
- spec/omniauth/strategies/inspur_spec.rb
|
|
117
|
+
- spec/spec_helper.rb
|
|
118
|
+
homepage: https://github.com/YuanZhencai/omniauth-inspur
|
|
119
|
+
licenses: []
|
|
120
|
+
metadata: {}
|
|
121
|
+
post_install_message:
|
|
122
|
+
rdoc_options: []
|
|
123
|
+
require_paths:
|
|
124
|
+
- lib
|
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '0'
|
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
|
+
requirements:
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: '0'
|
|
135
|
+
requirements: []
|
|
136
|
+
rubyforge_project:
|
|
137
|
+
rubygems_version: 2.7.7
|
|
138
|
+
signing_key:
|
|
139
|
+
specification_version: 4
|
|
140
|
+
summary: This is the strategy for authenticating to your Inspur service
|
|
141
|
+
test_files:
|
|
142
|
+
- spec/omniauth/strategies/inspur_spec.rb
|
|
143
|
+
- spec/spec_helper.rb
|