golden_ticket 0.9.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88d3c3e62e0b44471d956df0a2386185e0e06512
4
+ data.tar.gz: 7ba7e6702f9aa0078cb6e0e207623c3e9ca0d8ec
5
+ SHA512:
6
+ metadata.gz: 45a915876124de7d09af218720173c59b218d5e1d8edb30e1258a80d2b4ccaf2c0053665a2e650cde4889aab21811b29ae19779d516749c1abab0d76ac55943a
7
+ data.tar.gz: 9aeb95ef88f5d6d7e858c8d7e1ee8ce8b255eec68bf090bbf3ddf6d26213bfe611e99e1baea2aa80490317f624e76c426f862be9275b63af0bff67a2915336c1
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in corn_starch.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Paul Duncan
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,8 @@
1
+ # GoldenTicket
2
+
3
+ Simple JSON Web Token tools
4
+
5
+ ## License
6
+
7
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
8
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'golden_ticket/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "golden_ticket"
8
+ spec.version = GoldenTicket::VERSION
9
+ spec.authors = ["Eresse"]
10
+ spec.email = ["eresse@eresse.net"]
11
+
12
+ spec.summary = "Simple JWT Tools"
13
+ spec.description = "Provides simple tools to manipulate JSON Web Token"
14
+ spec.homepage = "http://redmine.eresse.net/projects/golden_ticket"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,3 @@
1
+ module GoldenTicket
2
+ VERSION = '0.9.2'
3
+ end
@@ -0,0 +1,43 @@
1
+ # GoldenTicket
2
+ # by Eresse <eresse@eresse.net>
3
+
4
+ # Includes
5
+ require 'base64'
6
+ require 'openssl'
7
+ require 'golden_ticket/version'
8
+
9
+ # GoldenTicket Module
10
+ module GoldenTicket
11
+
12
+ # Encode (Generate JWT)
13
+ def self.encode key, payload
14
+
15
+ # Prep Header - Always HMAC SHA 256 / JWT
16
+ header = { alg: 'HS256', typ: 'JWT' }
17
+ header_data = Base64.urlsafe_encode64 header.to_json
18
+
19
+ # Prepare Payload
20
+ payload_data = Base64.urlsafe_encode64 payload.to_json
21
+
22
+ # Compute Token Secret
23
+ secret = "#{header_data}.#{payload_data}"
24
+ secret_data = OpenSSL::HMAC.hexdigest OpenSSL::Digest.new('sha256'), key, secret
25
+
26
+ # Generate Token
27
+ "#{header_data}.#{payload_data}.#{secret_data}"
28
+ end
29
+
30
+ # Decode (Parse JWT)
31
+ def self.decode key, token
32
+
33
+ # Split Token
34
+ header_data, payload_data, secret_data = token.split '.'
35
+
36
+ # Verify Token
37
+ secret = "#{header_data}.#{payload_data}"
38
+ raise 'Invalid Token' unless secret_data == OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), key, secret)
39
+
40
+ # Pull dat Payload
41
+ JSON.parse Base64.urlsafe_decode64(payload_data)
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: golden_ticket
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.2
5
+ platform: ruby
6
+ authors:
7
+ - Eresse
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Provides simple tools to manipulate JSON Web Token
42
+ email:
43
+ - eresse@eresse.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - golden_ticket.gemspec
54
+ - lib/golden_ticket.rb
55
+ - lib/golden_ticket/version.rb
56
+ homepage: http://redmine.eresse.net/projects/golden_ticket
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.5.1
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Simple JWT Tools
80
+ test_files: []