omniauth-playstation 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33ac93735b063b0a800df69f264e6508676cc394
4
+ data.tar.gz: f28cb341bf649f7ecf7391a5ad48e30702d571a6
5
+ SHA512:
6
+ metadata.gz: b0befa92509b02231dd4b1dbeedad259680400aa89b54907bc48e835e1e3513183d3aef7870b8f00fda73af57a73b654a205a79685b504c8744221d5d69d1f88
7
+ data.tar.gz: 8425611f6b7742e3b5ef825940800140275b1d7597cf92f9ee81c4ba9812c1cdcdcfe73e0f7fafc518249a1bc5ccf3ff2568962570755558773f30d7c620f711
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :example do
6
+ gem 'sinatra'
7
+ end
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-playstation (0.1.0)
5
+ omniauth (> 1.0)
6
+ omniauth-oauth2 (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.3)
12
+ faraday (0.11.0)
13
+ multipart-post (>= 1.2, < 3)
14
+ hashie (3.5.5)
15
+ jwt (1.5.6)
16
+ multi_json (1.12.1)
17
+ multi_xml (0.6.0)
18
+ multipart-post (2.0.0)
19
+ oauth2 (1.3.1)
20
+ faraday (>= 0.8, < 0.12)
21
+ jwt (~> 1.0)
22
+ multi_json (~> 1.3)
23
+ multi_xml (~> 0.5)
24
+ rack (>= 1.2, < 3)
25
+ omniauth (1.6.1)
26
+ hashie (>= 3.4.6, < 3.6.0)
27
+ rack (>= 1.6.2, < 3)
28
+ omniauth-oauth2 (1.4.0)
29
+ oauth2 (~> 1.0)
30
+ omniauth (~> 1.2)
31
+ rack (1.6.5)
32
+ rack-protection (1.5.3)
33
+ rack
34
+ rake (12.0.0)
35
+ rspec (3.5.0)
36
+ rspec-core (~> 3.5.0)
37
+ rspec-expectations (~> 3.5.0)
38
+ rspec-mocks (~> 3.5.0)
39
+ rspec-core (3.5.4)
40
+ rspec-support (~> 3.5.0)
41
+ rspec-expectations (3.5.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.5.0)
44
+ rspec-mocks (3.5.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.5.0)
47
+ rspec-support (3.5.0)
48
+ sinatra (1.4.8)
49
+ rack (~> 1.5)
50
+ rack-protection (~> 1.4)
51
+ tilt (>= 1.3, < 3)
52
+ tilt (2.0.6)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ omniauth-playstation!
59
+ rake
60
+ rspec (>= 2.14.0)
61
+ sinatra
62
+
63
+ BUNDLED WITH
64
+ 1.13.7
@@ -0,0 +1,4 @@
1
+ omniauth-psn-oauth2
2
+ ===================
3
+
4
+ Oauth2 strategy for PSN (PlayStation Network)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require File.join('bundler', 'gem_tasks')
3
+ require File.join('rspec', 'core', 'rake_task')
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1 @@
1
+ require "omniauth/playstation"
@@ -0,0 +1 @@
1
+ require "omniauth/strategies/playstation"
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Playstation
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,97 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Playstation < OmniAuth::Strategies::OAuth2
6
+
7
+ option :name, 'playstation'
8
+ option :service_entity, 'urn:service-entity:psn'
9
+ option :authorize_options, [:service_entity, :response_type, :client_id, :redirect_uri, :scope]
10
+ @@force_ssl = true
11
+
12
+ def self.psn_env= value = 'sp-int'
13
+ option :psn_env, value
14
+ set_client_options
15
+ end
16
+
17
+ def self.psn_env
18
+ default_options[:psn_env]
19
+ end
20
+
21
+ def self.force_ssl= value
22
+ @@force_ssl = value
23
+ end
24
+
25
+ def self.force_ssl
26
+ @@force_ssl
27
+ end
28
+
29
+ def self.psn_auth_env
30
+ psn_env == 'np' ? '' : "#{psn_env}."
31
+ end
32
+
33
+ def self.set_client_options
34
+ option :client_options, {
35
+ site: "https://auth.api.#{psn_auth_env}sonyentertainmentnetwork.com",
36
+ info_url: "https://vl.api.#{psn_env}.ac.playstation.net/vl/api/v1/s2s/users/me/info"
37
+ }
38
+ end
39
+
40
+ def psn_env
41
+ self.class.psn_env
42
+ end
43
+
44
+ def force_ssl
45
+ @@force_ssl
46
+ end
47
+
48
+ def request_phase
49
+ redirect client.auth_code.authorize_url({:redirect_uri => redirect_uri}.merge(authorize_params))
50
+ end
51
+
52
+ def redirect_uri
53
+ if force_ssl
54
+ callback_url.gsub(/https?/,'https')
55
+ else
56
+ callback_url
57
+ end
58
+ end
59
+
60
+ def build_access_token
61
+ # generate Authorization header
62
+ auth = client.connection.basic_auth(options.client_id, options.client_secret)
63
+ options.token_params[:headers] = { "Authorization" => auth }
64
+
65
+ # remove code and state from callback_url
66
+ filtered_query_string = query_string.split('&').reject { |param| param =~ /code=|state=/ }.join
67
+ url = full_host + script_name + callback_path + filtered_query_string
68
+
69
+ # original implementation using url instead of callback_url
70
+ verifier = request.params["code"]
71
+ client.auth_code.get_token(verifier, {:redirect_uri => url}.merge(token_params.to_hash(:symbolize_keys => true)), deep_symbolize(options.auth_token_params))
72
+ end
73
+
74
+ uid { raw_info['user_id'] }
75
+
76
+ info do
77
+ {
78
+ username: raw_info['online_id'],
79
+ access_token: self.access_token.token
80
+ }
81
+ end
82
+
83
+ extra do
84
+ {
85
+ 'raw_info' => raw_info
86
+ }
87
+ end
88
+
89
+ def raw_info
90
+ auth_headers = { Authorization: client.connection.basic_auth(options.client_id, options.client_secret) }
91
+ @raw_info ||= JSON.parse(self.client.connection.run_request(:get, "https://auth.api.#{self.class.psn_auth_env}sonyentertainmentnetwork.com/2.0/oauth/token/#{self.access_token.token}", '', auth_headers).body)
92
+ rescue ::Errno::ETIMEDOUT
93
+ raise ::Timeout::Error
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require_relative "lib/omniauth/playstation/version"
3
+
4
+ Gem::Specification.new do |gem|
5
+
6
+ gem.authors = ["Rob Cataneo", "Yves Siegrist"]
7
+ gem.email = ["robcataneo@gmail.com", "Elektron1c97@gmail.com"]
8
+ gem.summary = %q{A PSN (PlayStation Network) OAuth2 strategy for OmniAuth 1.x}
9
+ gem.homepage = "https://github.com/siegy22/omniauth-playstation"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {spec}/*`.split("\n")
14
+ gem.name = "omniauth-playstation"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Playstation::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '> 1.0'
19
+ gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
20
+
21
+ gem.add_development_dependency 'rspec', '>= 2.14.0'
22
+ gem.add_development_dependency 'rake'
23
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-playstation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob Cataneo
8
+ - Yves Siegrist
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-03-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth-oauth2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.1'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.14.0
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.14.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description:
71
+ email:
72
+ - robcataneo@gmail.com
73
+ - Elektron1c97@gmail.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - Rakefile
82
+ - lib/omniauth-playstation.rb
83
+ - lib/omniauth/playstation.rb
84
+ - lib/omniauth/playstation/version.rb
85
+ - lib/omniauth/strategies/playstation.rb
86
+ - omniauth-contrib.gemspec
87
+ homepage: https://github.com/siegy22/omniauth-playstation
88
+ licenses: []
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.6.8
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: A PSN (PlayStation Network) OAuth2 strategy for OmniAuth 1.x
110
+ test_files: []