xctoken 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cbf954ab290ecf034013a801bd53e192f49e9483
4
+ data.tar.gz: 1739401f64eb4a6bde6122eb08e3d3b62cc903c6
5
+ SHA512:
6
+ metadata.gz: 795715f613064c5e2badcaa6693799738a2ba6de992079c5412a56082c7f6133007e6bab6e4368e41ba991da002a158dce86b32bf44a5bfd79b32e4f5f656d16
7
+ data.tar.gz: cfcd6367b9043be4a2d5284ef5bef64669140d0d9ca619e0dbe6a74662879add19e85ed991ea1ed14476fdb9d9ea1ae3c396597b59b3aa4963aaa6a22c179887
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.1
6
+ script: rake
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at shashikant.jagtap@icloud.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in xctoken.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ xctoken (0.1.0)
5
+ jwt (~> 2.1.0)
6
+ thor (~> 0.17.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.3)
12
+ jwt (2.1.0)
13
+ rake (10.5.0)
14
+ rspec (3.7.0)
15
+ rspec-core (~> 3.7.0)
16
+ rspec-expectations (~> 3.7.0)
17
+ rspec-mocks (~> 3.7.0)
18
+ rspec-core (3.7.1)
19
+ rspec-support (~> 3.7.0)
20
+ rspec-expectations (3.7.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-mocks (3.7.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-support (3.7.1)
27
+ thor (0.17.0)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.16)
34
+ rake (~> 10.0)
35
+ rspec (~> 3.7.0)
36
+ xctoken!
37
+
38
+ BUNDLED WITH
39
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Shashikant86
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # XCToken
2
+ ##### Generate on-demand JWT tokens forAppStore Connect API from Continuous Integration servers
3
+
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.
5
+
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.
7
+
8
+ ## Installation
9
+
10
+ Its unlikely that you iOS application's has Gemfile and bundler setup but. Just in case you use other Ruby libraries like CocoaPods or Fastlane for managing versions then add this to `Gemfile` :
11
+
12
+ ```ruby
13
+ gem 'xctoken'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it on Continuous Integration Server using following command
21
+
22
+ $ gem install xctoken
23
+
24
+ ## Usage
25
+
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.
27
+
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.
29
+
30
+ XCToken needs 3 envirnmental varibale setup to secure those credentials.
31
+
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
35
+
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.
37
+
38
+ ```
39
+ $ export ISSUER_ID=1234
40
+ $ export KEYDIR=/tmp
41
+ $ export KEY_ID=1234
42
+
43
+ ```
44
+
45
+ Now that, we all setup to generate the JWT tokens using XCToken by using following simple command.
46
+ ```
47
+ $ xctoken generate
48
+ ```
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
52
+
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
57
+
58
+
59
+
60
+ ## Development
61
+
62
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
63
+
64
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
65
+
66
+ ## Contributing
67
+
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Shashikant86/xctoken. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
69
+
70
+ ## License
71
+
72
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
73
+
74
+ ## Code of Conduct
75
+
76
+ Everyone interacting in the Xctoken project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Shashikant86/xctoken/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "xctoken"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/xctoken ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "xctoken"
5
+ require 'fileutils'
6
+ require 'tempfile'
7
+ require 'json'
8
+ require 'rubygems'
9
+ require 'xctoken/version'
10
+ require 'xctoken/main'
11
+
12
+ lib_dir = File.expand_path('../lib', File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
14
+ $:.unshift lib_dir unless $:.include?(lib_dir)
15
+
16
+ XCToken::Main.start(ARGV)
@@ -0,0 +1,41 @@
1
+ require 'thor'
2
+ require 'fileutils'
3
+ require 'xctoken/version'
4
+ require "base64"
5
+ require "jwt"
6
+ require 'openssl'
7
+
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"))
25
+
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
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Xctoken
2
+ VERSION = "0.1.0"
3
+ end
data/lib/xctoken.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "xctoken/version"
2
+
3
+ module Xctoken
4
+ # Your code goes here...
5
+ end
data/xctoken.gemspec ADDED
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "xctoken/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xctoken"
8
+ spec.version = Xctoken::VERSION
9
+ spec.authors = ["Shashikant86"]
10
+ spec.email = ["shashikant.jagtap@icloud.com"]
11
+
12
+ spec.summary = %q{Generate on-demand JWT Tokens for Apple's brand new AppStore Connect API from Continuous Integration Servers.}
13
+ spec.description = %q{Apple has introduced brand new AppStore Connect API whic requires JWT tokens to be generated after 20 minutes. XCToken can painlessly genarate JWT tokens at regular intervals from Continuous Integration Servers.}
14
+ spec.homepage = "https://github.com/Shashikant86/XCToken"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "bin"
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "thor", '~> 0.17.0'
27
+ spec.add_dependency "jwt", '~> 2.1.0'
28
+ spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.7.0"
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xctoken
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shashikant86
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.17.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.17.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: jwt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.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: 2.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.7.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.7.0
83
+ description: Apple has introduced brand new AppStore Connect API whic requires JWT
84
+ tokens to be generated after 20 minutes. XCToken can painlessly genarate JWT tokens
85
+ at regular intervals from Continuous Integration Servers.
86
+ email:
87
+ - shashikant.jagtap@icloud.com
88
+ executables:
89
+ - console
90
+ - setup
91
+ - xctoken
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - ".rspec"
97
+ - ".travis.yml"
98
+ - CODE_OF_CONDUCT.md
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - LICENSE.txt
102
+ - README.md
103
+ - Rakefile
104
+ - bin/console
105
+ - bin/setup
106
+ - bin/xctoken
107
+ - lib/xctoken.rb
108
+ - lib/xctoken/main.rb
109
+ - lib/xctoken/version.rb
110
+ - xctoken.gemspec
111
+ homepage: https://github.com/Shashikant86/XCToken
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.6.14
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Generate on-demand JWT Tokens for Apple's brand new AppStore Connect API
135
+ from Continuous Integration Servers.
136
+ test_files: []