apple_id 0.0.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 318e12c424935023b07b0340650d59d9c069495d5346bc2a1e7ded36046db68f
4
- data.tar.gz: cbd0f2478892599942de3cfaa1956f46d6d57ae60adc6ff9518375bf0849b5cb
3
+ metadata.gz: 57f3b090e123b3239c7ee81b0d54fb532d1cded860820d69f66985a5c764c789
4
+ data.tar.gz: 6f89d4c1685fd2b59220aab71e3a11d852ac75aaf6422c3b959626482467bb0f
5
5
  SHA512:
6
- metadata.gz: 3f2c23745d3e35f1997063f009b1fd57a72618f55bca337eba46f95313d0aae4d9c448d152696f6859d479b201fd2341ac0565f6f3e944eb646eeb88fff27113
7
- data.tar.gz: 7b1d2da5be7ac157edb610a0b6bd43c8b875f275a7f46ca094545cc5a1c2199c44ab55fb13b2bf6f9c4ae596cb5a80076eb1c6871bd4250a268bcbc3a52af69f
6
+ metadata.gz: bbe0117b9c67246b03b6814c5ba75f1fd7f893129cfdcac09d5ba9aa731f7f3f462cb233634a75acd6edd38ffeb34982a37b4591278271654a11a91d79d11170
7
+ data.tar.gz: 7541063a289eec294bcaadd363f6bbb23f937c42fd1334e6ff7be8a1e4a24e945cb62268cb91da896e256eca3060ea1bd402a9cee96b4566397a05b286453032
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -1,29 +1,26 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "apple_id/version"
5
-
6
1
  Gem::Specification.new do |spec|
7
- spec.name = "apple_id"
8
- spec.version = AppleID::VERSION
9
- spec.authors = ["nov"]
10
- spec.email = ["nov@matake.jp"]
2
+ spec.name = 'apple_id'
3
+ spec.version = File.read('VERSION')
4
+ spec.authors = ['nov']
5
+ spec.email = ['nov@matake.jp']
11
6
 
12
7
  spec.summary = %q{Sign-in with Apple Backend}
13
8
  spec.description = %q{Sign-in with Apple backend library in Ruby.}
14
- spec.homepage = "https://github.com/nov/apple_id"
15
- spec.license = "MIT"
9
+ spec.homepage = 'https://github.com/nov/apple_id'
10
+ spec.license = 'MIT'
16
11
 
17
12
  # Specify which files should be added to the gem when it is released.
18
13
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
14
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
15
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
16
  end
22
- spec.bindir = "exe"
17
+ spec.bindir = 'exe'
23
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
25
20
 
26
- spec.add_development_dependency "bundler", "~> 1.17"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
21
+ spec.add_runtime_dependency 'rack-oauth2', '~> 1.9.3'
22
+ spec.add_runtime_dependency 'openid_connect', '~> 1.0'
23
+ spec.add_development_dependency 'bundler', '~> 1.17'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
26
  end
@@ -1,6 +1,53 @@
1
- require "apple_id/version"
1
+ require 'openid_connect'
2
2
 
3
3
  module AppleID
4
- class Error < StandardError; end
5
- # Your code goes here...
4
+ ISSUER = 'https://appleid.apple.com'
5
+
6
+ VERSION = ::File.read(
7
+ ::File.join(::File.dirname(__FILE__), '../VERSION')
8
+ ).chomp
9
+
10
+ def self.logger
11
+ @@logger
12
+ end
13
+ def self.logger=(logger)
14
+ @@logger = logger
15
+ end
16
+ self.logger = Logger.new(STDOUT)
17
+ self.logger.progname = 'AppleID'
18
+
19
+ @sub_protocols = [
20
+ OpenIDConnect
21
+ ]
22
+ def self.debugging?
23
+ @@debugging
24
+ end
25
+ def self.debugging=(boolean)
26
+ @sub_protocols.each do |klass|
27
+ klass.debugging = boolean
28
+ end
29
+ @@debugging = boolean
30
+ end
31
+ def self.debug!
32
+ @sub_protocols.each do |klass|
33
+ klass.debug!
34
+ end
35
+ self.debugging = true
36
+ end
37
+ def self.debug(&block)
38
+ sub_protocol_originals = @sub_protocols.inject({}) do |sub_protocol_originals, klass|
39
+ sub_protocol_originals.merge!(klass => klass.debugging?)
40
+ end
41
+ original = self.debugging?
42
+ debug!
43
+ yield
44
+ ensure
45
+ @sub_protocols.each do |klass|
46
+ klass.debugging = sub_protocol_originals[klass]
47
+ end
48
+ self.debugging = original
49
+ end
50
+ self.debugging = false
6
51
  end
52
+
53
+ require 'apple_id/client'
@@ -0,0 +1,33 @@
1
+ module AppleID
2
+ class Client < OpenIDConnect::Client
3
+ attr_required :team_id, :key_id, :private_key
4
+
5
+ def initialize(attributes)
6
+ attributes_with_default = {
7
+ host: 'appleid.apple.com',
8
+ authorization_endpoint: '/auth/authorize',
9
+ token_endpoint: '/auth/token'
10
+ }.merge(attributes)
11
+ super attributes_with_default
12
+ end
13
+
14
+ def access_token!(options = {})
15
+ self.secret = client_secret_jwt
16
+ super :body, options
17
+ end
18
+
19
+ private
20
+
21
+ def client_secret_jwt
22
+ jwt = JSON::JWT.new(
23
+ iss: team_id,
24
+ aud: AppleID::ISSUER,
25
+ sub: identifier,
26
+ iat: Time.now,
27
+ exp: 1.minutes.from_now
28
+ )
29
+ jwt.kid = key_id
30
+ jwt.sign(private_key)
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov
@@ -10,6 +10,34 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.3
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.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: openid_connect
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'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,11 +95,12 @@ files:
67
95
  - LICENSE.txt
68
96
  - README.md
69
97
  - Rakefile
98
+ - VERSION
70
99
  - apple_id.gemspec
71
100
  - bin/console
72
101
  - bin/setup
73
102
  - lib/apple_id.rb
74
- - lib/apple_id/version.rb
103
+ - lib/apple_id/client.rb
75
104
  homepage: https://github.com/nov/apple_id
76
105
  licenses:
77
106
  - MIT
@@ -1,3 +0,0 @@
1
- module AppleID
2
- VERSION = "0.0.0"
3
- end