xctoken 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbf954ab290ecf034013a801bd53e192f49e9483
4
- data.tar.gz: 1739401f64eb4a6bde6122eb08e3d3b62cc903c6
3
+ metadata.gz: 59f5bfdc49268fa8dab7013f5a959217ef415135
4
+ data.tar.gz: 6a1e249716ae41e80d392879143e62fa7cd3d590
5
5
  SHA512:
6
- metadata.gz: 795715f613064c5e2badcaa6693799738a2ba6de992079c5412a56082c7f6133007e6bab6e4368e41ba991da002a158dce86b32bf44a5bfd79b32e4f5f656d16
7
- data.tar.gz: cfcd6367b9043be4a2d5284ef5bef64669140d0d9ca619e0dbe6a74662879add19e85ed991ea1ed14476fdb9d9ea1ae3c396597b59b3aa4963aaa6a22c179887
6
+ metadata.gz: d91cecdb8afed648dc4777731efe57254bd305177d570ed0305003f6bbd36975d8c5979b6ca370869552dba8ca20735462df487dc6a8cc9c01ad8daabcd3d941
7
+ data.tar.gz: d92ff1225cfd3e5a1fe7e1ff8d8dcb7493da5846acccdcfa9149f8d09a234620d36eda142b619ac07e6da7005854f0425c28b44d31e8e67e3da6c740a4f418ee
data/.travis.yml CHANGED
@@ -3,4 +3,6 @@ language: ruby
3
3
  rvm:
4
4
  - 2.4.1
5
5
  before_install: gem install bundler -v 1.16.1
6
- script: rake
6
+ script:
7
+ - bundle install
8
+ - bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xctoken (0.1.0)
4
+ xctoken (0.1.1)
5
5
  jwt (~> 2.1.0)
6
6
  thor (~> 0.17.0)
7
7
 
@@ -36,4 +36,4 @@ DEPENDENCIES
36
36
  xctoken!
37
37
 
38
38
  BUNDLED WITH
39
- 1.16.1
39
+ 1.16.4
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
+ [![CI Status](http://img.shields.io/travis/Shashikant86/XCToken.svg?style=flat&label=travisci)](https://travis-ci.org/Shashikant86/XCToken)
2
+
1
3
  # XCToken
2
- ##### Generate on-demand JWT tokens forAppStore Connect API from Continuous Integration servers
4
+ ##### Generate on-demand JWT tokens forAppStore Connect API from Continuous Integration servers
3
5
 
4
- Apple has announced AppStore Connect API to automate all the task related to Apple Developer Portal as well as iTunes Connect (recently known as AppStore Connect). You can watch WWDC session [303](https://developer.apple.com/videos/play/wwdc2018/303/) to know more about this API. App Store Connect API can now interact with almost all the part of Apple Developer portal including, certificates, profiles and devices. App Store connect API will also touch almost all section of iTunes Connect which is remaned as App Store Connect including manging users and builds. However, this API requires JWT tokens to recieve response. Users needs to create tokens after every 20 minutes.
6
+ Apple has announced AppStore Connect API to automate all the task related to Apple Developer Portal as well as iTunes Connect (recently known as AppStore Connect). You can watch WWDC session [303](https://developer.apple.com/videos/play/wwdc2018/303/) to know more about this API. App Store Connect API can now interact with almost all the part of Apple Developer portal including, certificates, profiles and devices. App Store connect API will also touch almost all section of iTunes Connect which is remaned as App Store Connect including manging users and builds. However, this API requires JWT tokens to recieve response. Users needs to create tokens after every 20 minutes.
5
7
 
6
- XCToken is a Ruby library to generate on-demand tokens for the AppStore Connect API so that we can create tokens using this library without need to write custom scripts on Continuous Integration Servers.
8
+ XCToken is a Ruby library to generate on-demand tokens for the AppStore Connect API so that we can create tokens using this library without need to write custom scripts on Continuous Integration Servers.
7
9
 
8
10
  ## Installation
9
11
 
@@ -17,45 +19,51 @@ And then execute:
17
19
 
18
20
  $ bundle install
19
21
 
20
- Or install it on Continuous Integration Server using following command
22
+ Or install it on Continuous Integration Server using following command
21
23
 
22
24
  $ gem install xctoken
23
25
 
24
26
  ## Usage
25
27
 
26
- > Note: At the moment, AppStore Connect API has not released to public Yet nor the AppStore Connect GUI available to experiemnt. So there is no wat to test this library in real world envirnment until Apple release AppStore Connect API to public.
28
+ #### Warning: **** This is early stage of library and not ready to use yet until Apple releases AppStore Connect API ****
29
+
30
+ > Note: At the moment, AppStore Connect API has not released to public Yet nor the AppStore Connect GUI available to experiemnt. So there is no wat to test this library in real world envirnment until Apple release AppStore Connect API to public.
27
31
 
28
- AppStore Connect API deals with very sensitive information so security is very important aspect. The new AppStore Connect GUI will have ability to generate API KEY and Private Key for API. We should also able to see ISSUER_ID in the AppStore Connect GUI.
32
+ AppStore Connect API deals with very sensitive information so security is very important aspect. The new AppStore Connect GUI will have ability to generate API KEY and Private Key for API. We should also able to see ISSUER_ID in the AppStore Connect GUI.
29
33
 
30
- XCToken needs 3 envirnmental varibale setup to secure those credentials.
34
+ XCToken needs 3 environmental variable setup to secure those credentials.
31
35
 
32
- * `ISSUER_ID` : You can get it from AppStore Connect GUI
33
- * `KEY_DIR` : AppStore Connect has a way to generate private key. We have to keep this key secure and always has associated `KEY_ID` the private key is in the `.p8` format and reads like `AuthKey_KEY_ID.p8`. XCToken requires path to the directory where this private key located. e.g `/tmp` if you have private key at the path `/tmp/Auth_Key_1234.p8`
34
- * `KEY_ID` : Every private key has KEY_ID we can set that as envirnment varilable as well
36
+ * `ISSUER_ID` : You can get it from AppStore Connect GUI
37
+ * `KEY_DIR` : AppStore Connect has a way to generate private key. We have to keep this key secure and always has associated `KEY_ID` the private key is in the `.p8` format and reads like `AuthKey_KEY_ID.p8`. XCToken requires path to the directory where this private key located. e.g `/tmp` if you have private key at the path `/tmp/AuthKey_1234.p8`
38
+ * `KEY_ID` : Every private key has KEY_ID we can set that as envirnment variable as well
35
39
 
36
- On Continuous Integration server, we can secure these credential using Envirnmental Varibale feature of specific CI server. These details shouldn't be exposed or hardcoded. You can enrypt and decrypt the `.p8` format private key on CI server to add extra layer of security.
40
+ On Continuous Integration server, we can secure these credential using Envirnmental Variable feature of specific CI server. These details shouldn't be exposed or hardcoded. You can enrypt and decrypt the `.p8` format private key on CI server to add extra layer of security.
37
41
 
38
42
  ```
39
43
  $ export ISSUER_ID=1234
40
- $ export KEYDIR=/tmp
44
+ $ export KEY_DIR=/tmp
41
45
  $ export KEY_ID=1234
42
46
 
43
47
  ```
44
48
 
45
- Now that, we all setup to generate the JWT tokens using XCToken by using following simple command.
49
+ Now that, we all setup to generate the JWT tokens using XCToken by using following simple command.
46
50
  ```
47
- $ xctoken generate
51
+ $ xctoken generate
48
52
  ```
49
- This will print the fresh token that we can use for the AppStore Connect API. We can run this command every time we need fresh token from CI server.
50
-
51
- ## TODO
53
+ This will print the fresh token that we can use for the AppStore Connect API. We can run this command every time we need fresh token from CI server.
52
54
 
53
- * Test the library when Apple releases API
54
- * Add more options to generate token with multiple algorithms and expriry time
55
- * Ability to use keep token secret rather than printing to console
56
- * Add more RSpec Tests
55
+ We can pass the printed token to an API call like so:
56
+ ```
57
+ TOKEN=`xctoken generate`
58
+ curl -H "Authorization: Bearer $TOKEN" https://api.appstoreconnect.apple.com/v1/users
59
+ ```
57
60
 
61
+ ## TODO
58
62
 
63
+ * Test the library when Apple releases API
64
+ * Add more options to generate token with multiple algorithms and expriry time
65
+ * Ability to use keep token secret rather than printing to console
66
+ * Add more RSpec Tests
59
67
 
60
68
  ## Development
61
69
 
data/lib/xctoken/main.rb CHANGED
@@ -6,36 +6,39 @@ require "jwt"
6
6
  require 'openssl'
7
7
 
8
8
  module XCToken
9
- class Main < Thor
10
- include Thor::Actions
11
- desc "generate", "Genarate AppStore Connect Token"
12
- def generate
13
- issuer_id = ENV["ISSUER_ID"]
14
- key_id = ENV["KEY_ID"]
15
- key_dir = ENV["KEY_DIR"]
16
-
17
- if File.file?('#{key_dir}/AuthKey_#{key_id}.p8')
18
- puts "Private Key Exist in the correct format with and matching identifier"
19
- else
20
- puts "Private key not found in the specified directory with key identifier assiciated"
21
- puts "Please make sure KEY_DIR and KEY_ID environmetal varibales set correctly and private key exist in the KEY_DIR"
22
- raise 'Private Key not setup correctly. Please make sure ENV[KEY_DIR] has private key'
23
- end
24
- $private_key = OpenSSL::PKey.read(File.read("#{key_dir}/AuthKey_#{key_id}.p8"))
9
+ class Main < Thor
10
+ include Thor::Actions
25
11
 
26
- $token = JWT.encode(
27
- {
28
- iss: issuer_id,
29
- exp: Time.now.to_i + 20 * 60,
30
- aud: "appstoreconnect-v1"
31
- },
32
- private_key,
33
- "ES256",
34
- header_fields = {
35
- kid: 1234,
36
- }
37
- )
38
- puts $token
12
+ desc "generate", "Genarate AppStore Connect Token"
13
+ def generate
14
+ issuer_id = ENV["ISSUER_ID"]
15
+ key_id = ENV["KEY_ID"]
16
+ key_dir = ENV["KEY_DIR"]
17
+
18
+ full_key_path = "#{key_dir}/AuthKey_#{key_id}.p8"
19
+
20
+ if !File.file?(full_key_path)
21
+ puts "Private key not found in the specified directory with key identifier assiciated"
22
+ puts "Please make sure KEY_DIR and KEY_ID environmetal varibales set correctly and private key exist in the KEY_DIR"
23
+ raise 'Private Key not setup correctly. Please make sure ENV[KEY_DIR] has private key'
24
+ end
25
+
26
+ private_key = OpenSSL::PKey.read(File.read(full_key_path))
27
+
28
+ $token = JWT.encode(
29
+ {
30
+ iss: issuer_id,
31
+ exp: Time.now.to_i + 20 * 60,
32
+ aud: "appstoreconnect-v1"
33
+ },
34
+ private_key,
35
+ "ES256",
36
+ header_fields = {
37
+ kid: key_id,
38
+ }
39
+ )
40
+ puts $token
41
+
42
+ end
39
43
  end
40
- end
41
- end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Xctoken
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xctoken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shashikant86
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor