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.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/lib/gemon.rb +14 -1
- data/lib/gemon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e96dc9e0478682243a5f542188c7d3accf45400
|
4
|
+
data.tar.gz: 4fdaf9eb576a40a560d5e5074e56d5e891753470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/gemon.rb
CHANGED
@@ -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 => {
|
data/lib/gemon/version.rb
CHANGED