heartcheck-cas 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/heartcheck/cas/http_client.rb +24 -0
- data/lib/heartcheck/cas/version.rb +5 -0
- data/lib/heartcheck/cas.rb +8 -0
- data/lib/heartcheck/checks/cas.rb +43 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWEzZmIwN2E0YmViYmEwNzBjMTYxZDA1NzEyZDc4MDZlOTA2MmQ0Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MzhkMGNjNDc4ZjNiY2Y5NmNkYzQxZDU1NmM0ODc3NDk3MWEzNWE5Zg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjhlZjRhNWUwNjQ4OGI4OWQzYWE4ODJmMWFjN2NlZmEzNGM3MzY4OTY4NjBh
|
10
|
+
MDkyNGRlNjMzNWZjNGE1ZDliNTFiZWZiNWQzMzZkMjQ0OTg1ODQwODVjMGFk
|
11
|
+
OGMyY2ZmZmYxNGU1ZjQ2MjFiN2NhMjM4MjkzODIxZWUyYzQ2ZTk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MWQ0OTVmYzM1YWEwMTZiNTU2OTVjZTEwNmE1ZDExYThjZmYyMjI2MGNkNmZl
|
14
|
+
OGMyNzU5NzFlYmY0ODA4ODNjMmYxMTdlMzE1Mjg2OTYxOWI5Y2Y1NjM3NDRi
|
15
|
+
YTY3NzliNzAzNTIzNmIzMzA1YzNhMjFmY2JjMzEwNjIyY2ZjZGM=
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# enconding: utf-8
|
2
|
+
module Heartcheck
|
3
|
+
module Cas
|
4
|
+
class HttpClient
|
5
|
+
def self.post(url, params)
|
6
|
+
self.new.post(url, params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(url, params)
|
10
|
+
uri = URI(url)
|
11
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
12
|
+
request.set_form_data(params)
|
13
|
+
base_client(uri).request(request)
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_client(uri)
|
17
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
18
|
+
http.use_ssl = uri.scheme.eql?('https')
|
19
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
20
|
+
http
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Heartcheck
|
4
|
+
module Checks
|
5
|
+
class Cas < Base
|
6
|
+
def validate
|
7
|
+
services.each do |service|
|
8
|
+
begin
|
9
|
+
tgt = tgt_url(service)
|
10
|
+
|
11
|
+
if tgt.nil?
|
12
|
+
@errors << "Cannot get TGT"
|
13
|
+
next
|
14
|
+
end
|
15
|
+
|
16
|
+
if ticket(service, tgt).nil?
|
17
|
+
@errors << "Cannot get ticket"
|
18
|
+
next
|
19
|
+
end
|
20
|
+
rescue StandardError => e
|
21
|
+
@errors << e.message
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def tgt_url(service)
|
29
|
+
response = Heartcheck::Cas::HttpClient.post(service[:server], {
|
30
|
+
'username' => service[:username],
|
31
|
+
'password' => service[:password]
|
32
|
+
})
|
33
|
+
|
34
|
+
response.code.eql?('201') ? response['Location'] : nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def ticket(service, tgt)
|
38
|
+
response = Heartcheck::Cas::HttpClient.post(tgt, {'service' => service[:service]})
|
39
|
+
response.code.eql?('200') ? response.body : nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heartcheck-cas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- andrerocker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-08 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-nav
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.4
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: heartcheck
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
description: Provides cas checkers to heartcheck
|
84
|
+
email:
|
85
|
+
- andre.souza@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- lib/heartcheck/cas.rb
|
91
|
+
- lib/heartcheck/cas/http_client.rb
|
92
|
+
- lib/heartcheck/cas/version.rb
|
93
|
+
- lib/heartcheck/checks/cas.rb
|
94
|
+
homepage: http://github.com/locaweb/heartcheck-cas
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.8
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: cas checkers to heartcheck
|
118
|
+
test_files: []
|