authify-core 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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/authify-core.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/authify/core/constants/jwt_scopes.rb +10 -0
- data/lib/authify/core/helpers/jwt_ssl.rb +18 -0
- data/lib/authify/core/secure_hashing.rb +44 -0
- data/lib/authify/core/version.rb +9 -0
- data/lib/authify/core.rb +27 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ad10017b23fa8d47835877612abaa308da1716e8
|
4
|
+
data.tar.gz: 27a5916b25e2faad2d7f4f918b3c82f1a884cba6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d8952b436b36302aedfdfea9735250af8a5873e8a5421a9390260beb2381fbc220e01493b4b642e27df8d52aa1db701963581bc58e28c173488b6bdbfe479930
|
7
|
+
data.tar.gz: 89f646f362e746c5d10ff2d09571dc1f587060668d1c39b6f460a34fa2023eca5ad568a3ad3a3e35e525e467e042c850b10a0f0fcefd07f9880b84c0e807c9fc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.1
|
5
|
+
before_install: gem install bundler -v 1.12.5
|
6
|
+
deploy:
|
7
|
+
provider: rubygems
|
8
|
+
api_key:
|
9
|
+
secure: Ox4UKjh6/j5OifMLRrijDuAknX3VUzw79oc/ayrKdLk4kpRgn8AXk9lWC4E8GjhjEzdvxT/X70OzJJTBaFYVt3uwvDnICBj27+kpUZTNtMW4aUfv4Mxw4S6lk2Q2TD5g/mNcJvF6SpoAu92buca32SHUiTIdS+4UgHTAEadP73Ty94nOBFQPTZKCasFR5V3iNNjHxByrZMZ57woj7MgXQ2e4GMnk/AB+ZTW97oCsk9dyh9R/IM3GVS1XIHff10uFnF2EFgdGslnKavwUunHcePArdj8PZ7toAAxk7SaiY+GgKOizZ149tcz0m9fiEiJE5n/mCASiq/DRBqIqbsVRuYM8xV73d+DmtYUMX/SwgMmLG+ll8O/nyG9tofAB0BoRFQmLltpLNz07Cm1mIXslLixMxTySOUQKysol4PxzUBUvGlVxlFnxNfgBUOc5XcP4N6xmh4sdm5gWwRXmc4P2NLUhuTkqmFA8DZb9J7h3JSkE6LGoDlUHvIzlJQrVB94x28rwO2FMMCjL+RTnYIocAVcIH6ebr8IGAoostc9H9Tc/K90DU2oBUho5zofpyv9OhrOHlqxG/Mit4rS5OVlYq9FUjr2M3OYb/jHxl7Izv9vzkIPW74lm5+4lpOm0vuygdK65+WiQ728s4tJ6u4Ig44ugcR6qUxX1mD4XHPtjwdI=
|
10
|
+
gem: authify-core
|
11
|
+
on:
|
12
|
+
tags: true
|
13
|
+
repo: knuedge/authify-core
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 KnuEdge
|
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,41 @@
|
|
1
|
+
# Authify::Core
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/authify/core`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'authify-core'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install authify-core
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/authify-core.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'authify/core/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'authify-core'
|
8
|
+
spec.version = Authify::Core::VERSION
|
9
|
+
spec.authors = ['Jonathan Gnagy']
|
10
|
+
spec.email = ['jgnagy@knuedge.com']
|
11
|
+
|
12
|
+
spec.summary = 'Authify Core library'
|
13
|
+
spec.homepage = 'https://github.com/knuedge/authify-core'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.required_ruby_version = '~> 2.0'
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'jwt', '~> 1.5'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.35'
|
31
|
+
spec.add_development_dependency 'yard', '~> 0.8'
|
32
|
+
spec.add_development_dependency 'travis', '~> 1.8'
|
33
|
+
spec.add_development_dependency 'simplecov', '~> 0.13'
|
34
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'authify/core'
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Authify
|
2
|
+
module Core
|
3
|
+
module Helpers
|
4
|
+
# Helpers for accessing the SSL certs used for JWT
|
5
|
+
module JWTSSL
|
6
|
+
def private_key
|
7
|
+
path = File.expand_path(CONFIG[:ssl][:private])
|
8
|
+
OpenSSL::PKey::EC.new File.read(path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def public_key
|
12
|
+
path = File.expand_path(CONFIG[:ssl][:public])
|
13
|
+
OpenSSL::PKey::EC.new File.read(path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Authify
|
2
|
+
module Core
|
3
|
+
# Some handy methods for SHA512 and Base64
|
4
|
+
module SecureHashing
|
5
|
+
# Convert a string to a Base64 encoded version of itself
|
6
|
+
# @return [String]
|
7
|
+
def to_64(string)
|
8
|
+
Base64.encode64(string).chomp.delete("\n")
|
9
|
+
end
|
10
|
+
|
11
|
+
# Decode a Base64 encoded string
|
12
|
+
# @return [String]
|
13
|
+
def decode64
|
14
|
+
Base64.decode64(string)
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hex(data)
|
18
|
+
data.unpack('H*').first.chomp.delete("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def sha512(string)
|
22
|
+
to_hex(Digest::SHA512.digest(string))
|
23
|
+
end
|
24
|
+
|
25
|
+
def salted_sha512(string, salt = nil)
|
26
|
+
salt ||= rand(9**99).to_s[0...16]
|
27
|
+
sha512(string + salt) + salt
|
28
|
+
end
|
29
|
+
|
30
|
+
def compare_salted_sha512(string, hashed_string)
|
31
|
+
salt = hashed_string[-16..-1]
|
32
|
+
salted_sha512(string, salt) == hashed_string
|
33
|
+
end
|
34
|
+
|
35
|
+
def peppered_sha512(seed, pepper = rand(9**99).to_s)
|
36
|
+
# Run our string through 10 rounds of SHA512, each time "peppering" it with random data
|
37
|
+
10.times do
|
38
|
+
seed = sha512(seed + pepper)
|
39
|
+
end
|
40
|
+
seed
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/authify/core.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Standard Library Requirements
|
2
|
+
require 'json'
|
3
|
+
require 'digest/sha2'
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
# External Requirements
|
7
|
+
require 'jwt'
|
8
|
+
require 'openssl'
|
9
|
+
|
10
|
+
module Authify
|
11
|
+
module Core
|
12
|
+
CONFIG = {
|
13
|
+
ssl: {
|
14
|
+
public: ENV['AUTHIFY_PUBKEY_PATH'] || File.join('~', '.authify', 'ssl', 'public.pem'),
|
15
|
+
private: ENV['AUTHIFY_PRIVKEY_PATH'] || File.join('~', '.authify', 'ssl', 'private.pem')
|
16
|
+
},
|
17
|
+
jwt: {
|
18
|
+
issuer: ENV['AUTHIFY_JWT_ISSUER'] || 'My Awesome Company Inc.'
|
19
|
+
}
|
20
|
+
}.freeze
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'authify/core/version'
|
25
|
+
require 'authify/core/secure_hashing'
|
26
|
+
require 'authify/core/constants/jwt_scopes'
|
27
|
+
require 'authify/core/helpers/jwt_ssl'
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: authify-core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Gnagy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.35'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.35'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: travis
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.8'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.13'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.13'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- jgnagy@knuedge.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- authify-core.gemspec
|
141
|
+
- bin/console
|
142
|
+
- bin/setup
|
143
|
+
- lib/authify/core.rb
|
144
|
+
- lib/authify/core/constants/jwt_scopes.rb
|
145
|
+
- lib/authify/core/helpers/jwt_ssl.rb
|
146
|
+
- lib/authify/core/secure_hashing.rb
|
147
|
+
- lib/authify/core/version.rb
|
148
|
+
homepage: https://github.com/knuedge/authify-core
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '2.0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.5.1
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Authify Core library
|
172
|
+
test_files: []
|