omniauth-wip 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/omniauth-wip.rb +2 -0
- data/lib/omniauth-wip/version.rb +5 -0
- data/lib/omniauth/strategies/wip.rb +76 -0
- data/omniauth-wip.gemspec +22 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 06e9db3321c93aac3dbdcaaadfbc5653155ed859f17f912abb36d7254de2ae6d
|
4
|
+
data.tar.gz: 001e7e8cf834d6b36f3f3fecff092d45fc91b8a906af154a55488efb0fe66cfa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9edfc5eb9ddb0b6c05b3b776e2293c5ed1ad22e9cd24de29cb088b1b377107c4b116a665051f52ae24261994823ced1f5241ec60b64b17aece9384c5f175ff22
|
7
|
+
data.tar.gz: 8bd9e808695b10bd80204b9dd56b64f4160d1ff43bdad299eb5a293df8349a3efabb906a6a12682f08855c8277591fa419f68e4feeb9cd0bdba52e744ba21269
|
data/lib/omniauth-wip.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "omniauth-oauth2"
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class WIP < OmniAuth::Strategies::OAuth2
|
8
|
+
option :name, "wip"
|
9
|
+
|
10
|
+
option :client_options,
|
11
|
+
site: "https://wip.chat",
|
12
|
+
authorize_url: "/oauth/authorize"
|
13
|
+
|
14
|
+
uid { raw_info["id"] }
|
15
|
+
|
16
|
+
info do
|
17
|
+
{
|
18
|
+
username: raw_info["username"],
|
19
|
+
url: raw_info["url"],
|
20
|
+
name: [raw_info["first_name"], raw_info["last_name"]].compact.join(" ")
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
extra do
|
25
|
+
{
|
26
|
+
raw_info: raw_info
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def raw_info
|
31
|
+
@raw_info ||= wip_client
|
32
|
+
end
|
33
|
+
|
34
|
+
# https://github.com/intridea/omniauth-oauth2/issues/81
|
35
|
+
def callback_url
|
36
|
+
full_host + script_name + callback_path
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def wip_client
|
42
|
+
data = make_request viewer_query
|
43
|
+
data["viewer"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def viewer_query
|
47
|
+
%(
|
48
|
+
{
|
49
|
+
viewer {
|
50
|
+
id
|
51
|
+
username
|
52
|
+
url
|
53
|
+
first_name
|
54
|
+
last_name
|
55
|
+
}
|
56
|
+
}
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def make_request(query)
|
61
|
+
response = Faraday.post("https://wip.chat/graphql") do |request|
|
62
|
+
request.headers["Authorization"] = "bearer #{credentials["token"]}"
|
63
|
+
request.headers["Content-Type"] = "application/json"
|
64
|
+
request.body = { query: query }.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
json = JSON.parse(response.body)
|
68
|
+
raise json["errors"].first["message"] if json.key? "errors"
|
69
|
+
|
70
|
+
json["data"]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
OmniAuth.config.add_camelization "wip", "WIP"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path("../lib/omniauth-wip/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Marc Köhlbrugge"]
|
5
|
+
gem.email = ["marc@wip.chat"]
|
6
|
+
gem.description = "WIP (wip.chat) OAuth 2 Strategy for OmniAuth."
|
7
|
+
gem.summary = gem.description
|
8
|
+
gem.homepage = "https://github.com/marckohlbrugge/omniauth-wip"
|
9
|
+
gem.license = "MIT"
|
10
|
+
|
11
|
+
gem.add_dependency "omniauth", "~> 1.9"
|
12
|
+
gem.add_dependency "omniauth-oauth2", "~> 1.6"
|
13
|
+
gem.add_dependency "faraday", "~> 1.0"
|
14
|
+
gem.add_development_dependency "bundler", "~> 1.9"
|
15
|
+
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
|
+
gem.files = `git ls-files`.split("\n")
|
18
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
gem.name = "omniauth-wip"
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
gem.version = OmniAuth::WIP::VERSION
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-wip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marc Köhlbrugge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-12 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.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
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.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.9'
|
69
|
+
description: WIP (wip.chat) OAuth 2 Strategy for OmniAuth.
|
70
|
+
email:
|
71
|
+
- marc@wip.chat
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/omniauth-wip.rb
|
77
|
+
- lib/omniauth-wip/version.rb
|
78
|
+
- lib/omniauth/strategies/wip.rb
|
79
|
+
- omniauth-wip.gemspec
|
80
|
+
homepage: https://github.com/marckohlbrugge/omniauth-wip
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubygems_version: 3.0.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: WIP (wip.chat) OAuth 2 Strategy for OmniAuth.
|
103
|
+
test_files: []
|