gemon 0.0.1 → 0.0.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -0
  3. data/lib/gemon.rb +14 -1
  4. data/lib/gemon/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36e1563daa8590611bed955ed24257f384205248
4
- data.tar.gz: beb11c4e74c83c3b1add933e3e0750fbc22edde6
3
+ metadata.gz: 4e96dc9e0478682243a5f542188c7d3accf45400
4
+ data.tar.gz: 4fdaf9eb576a40a560d5e5074e56d5e891753470
5
5
  SHA512:
6
- metadata.gz: 65c52ae466f4239184699a75e202186f4e01128fec7b1f9097748786dc617c3fbaf6fe697c9d80ab57711da6da50feaacb3217fe0a2b60cb40861cff3540128f
7
- data.tar.gz: 9d08098bc54ec9e8a465c7ceabd1c1c3182b75cb7743cc6fa0f04931d0ced24b360a220a1147920dea1a1487b993a15d9da4367c4fbfbefa1edec90d7767a6ec
6
+ metadata.gz: f55d12460952fa9b0bee854b3494aa5f094773a5d3893797159c892cd545c136f1f21585f1fa72fcdc436a39b387eccfa2776f4357ba9d8e7ec03a1e9eaf283a
7
+ data.tar.gz: c118a99260d6707f0d056b24d0c8ad5b95da3522fff5c996068a76657441437e37fe8720f6b59a3b751b0a0d58620e0018e6eb1598ea3514c958f05e5254335d
data/README.md CHANGED
@@ -22,6 +22,23 @@ mount Gemon::Server, at: "/appstatus"
22
22
 
23
23
  In the above example the json data will be available on /appstatus in your Rails app.
24
24
 
25
+ ## Security
26
+
27
+ To secure your genom endpoint, create an initializer in your Rails app eg `config/initializers/genom.rb`
28
+
29
+ Add a Genom.api_key to config/initializer file.
30
+
31
+ ```
32
+ Genom.api_key = "123456" # random string
33
+ ```
34
+
35
+ Then when calling the endpoint add the key to the request.
36
+
37
+ ```
38
+ /appstatus?key=123456
39
+ ```
40
+
41
+ If the key isn't set then there is no security on the endpoint.
25
42
 
26
43
  ## Contributing
27
44
 
@@ -30,3 +47,9 @@ In the above example the json data will be available on /appstatus in your Rails
30
47
  3. Commit your changes (`git commit -am 'Add some feature'`)
31
48
  4. Push to the branch (`git push origin my-new-feature`)
32
49
  5. Create new Pull Request
50
+
51
+ ## ToDo
52
+
53
+ 1. More tests
54
+ 2. A generator to generate the initializer file and fill it with a random key.
55
+ 3. More documentation on what results are returned.
@@ -4,6 +4,12 @@ require "bundler"
4
4
  require "json"
5
5
 
6
6
  module Gemon
7
+ class << self
8
+
9
+ attr_accessor :api_key
10
+
11
+ end
12
+
7
13
  class Server < Sinatra::Base
8
14
 
9
15
  dir = File.dirname(File.expand_path(__FILE__))
@@ -11,11 +17,18 @@ module Gemon
11
17
  set :static, true
12
18
 
13
19
  get '/' do
20
+ content_type :json
21
+
22
+ if !Gemon.api_key.nil?
23
+ if params[:key] != Gemon.api_key
24
+ return {:error => "Invalid Key"}.to_json
25
+ end
26
+ end
27
+
14
28
  dir = File.expand_path("..",Dir.pwd)
15
29
  dir = Dir.pwd
16
30
  gemfile = dir + "/Gemfile.lock"
17
31
  lockfile = Bundler::LockfileParser.new(Bundler.read_file(gemfile))
18
- content_type :json
19
32
  {
20
33
  :ruby => ruby_version,
21
34
  :os => {
@@ -1,3 +1,3 @@
1
1
  module Gemon
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Zolkos