auth-lh 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE.md +22 -0
- data/README.md +29 -0
- data/lib/auth/lh.rb +10 -0
- data/lib/auth/lh/api.rb +53 -0
- data/lib/auth/lh/login_attempt.rb +13 -0
- data/lib/auth/lh/session_response.rb +17 -0
- data/lib/auth/lh/user.rb +14 -0
- data/lib/auth/lh/version.rb +5 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 96c235602e2827077484c072fd1739ef9b872824
|
4
|
+
data.tar.gz: 619b0d251b32b8c18df7b454ea715ab8be5de8ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c56c689dd659850fabb8a1e62a2fe956757937f16de4a110998a68a8233cd75b9fabde65c61584e47219dee4699890a71de2a0af6f017ca926a71582f079f1d
|
7
|
+
data.tar.gz: 10b677a66de6d83930435366bc817687d1e73d8894d37051b1387731c4607ba4b2ecbf1df245e2ce07c6753d22d66e6b5f7a39d556a4ac7aba78c8980f417187
|
data/CHANGELOG.md
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 unformatt
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Auth::Lh
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'auth-lh'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install auth-lh
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/lib/auth/lh.rb
ADDED
data/lib/auth/lh/api.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Auth
|
2
|
+
module Lh
|
3
|
+
class Api
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
attr_accessor :endpoint, :return_url, :application_code
|
7
|
+
|
8
|
+
def self.configure(args={})
|
9
|
+
instance.endpoint = (args[:endpoint] || 'https://auth.lhconfort.com.ar')
|
10
|
+
instance.return_url = args[:return_url]
|
11
|
+
instance.application_code = args[:application_code]
|
12
|
+
end
|
13
|
+
|
14
|
+
def logged_user(session_token, remote_ip)
|
15
|
+
result = get_request '/logged_user', {
|
16
|
+
app_code: @application_code,
|
17
|
+
session_token: session_token,
|
18
|
+
remote_ip: remote_ip
|
19
|
+
}
|
20
|
+
|
21
|
+
SessionResponse.new(result)
|
22
|
+
end
|
23
|
+
|
24
|
+
def login_url
|
25
|
+
login_attempt = create_login_attempt
|
26
|
+
"#{@endpoint_url}/login?attempt=#{login_attempt.token}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def logout_url
|
30
|
+
"#{@endpoint_url}/logout?return=#{CGI::escape(@return_url)}"
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def create_login_attempt
|
36
|
+
result = post_request '/login_attempts', {
|
37
|
+
app_code: @application_code,
|
38
|
+
return_url: @return_url
|
39
|
+
}
|
40
|
+
|
41
|
+
LoginAttempt.new(result)
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_request(action, params={})
|
45
|
+
JSON.parse(RestClient.get("#{@endpoint_url}#{action}", {params: params}))
|
46
|
+
end
|
47
|
+
|
48
|
+
def post_request(action, params={})
|
49
|
+
JSON.parse(RestClient.post("#{@endpoint_url}#{action}", params))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Auth
|
2
|
+
module Lh
|
3
|
+
class SessionResponse
|
4
|
+
attr_accessor :user, :success, :reason, :login_url
|
5
|
+
|
6
|
+
def initialize(attributes={})
|
7
|
+
attributes.each do |k,v|
|
8
|
+
if k.to_s == 'user'
|
9
|
+
self.user = Auth::User.new(v) if v.present?
|
10
|
+
else
|
11
|
+
self.send("#{k}=", v)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/auth/lh/user.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: auth-lh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matias Hick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-18 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.7
|
55
|
+
description: Authentication with auth lh api
|
56
|
+
email:
|
57
|
+
- unformatt@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENSE.md
|
63
|
+
- README.md
|
64
|
+
- CHANGELOG.md
|
65
|
+
- lib/auth/lh/api.rb
|
66
|
+
- lib/auth/lh/login_attempt.rb
|
67
|
+
- lib/auth/lh/session_response.rb
|
68
|
+
- lib/auth/lh/user.rb
|
69
|
+
- lib/auth/lh/version.rb
|
70
|
+
- lib/auth/lh.rb
|
71
|
+
homepage: https://github.com/unformattmh/auth-lh
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.1.11
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Authentication with auth lh api
|
95
|
+
test_files: []
|