auth-lh 0.0.12 → 0.1.0
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/CHANGELOG.md +4 -0
- data/lib/auth/lh/version.rb +1 -1
- data/lib/auth/lh.rb +2 -0
- data/lib/auth_lh/authentication.rb +70 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48376fcc85242fcfd3079c282e64b429d0ddc8cd
|
4
|
+
data.tar.gz: 6b6cb95697decb7b272e04ad98941c94472e5645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 599864c095c43e7bcc0568e0acf4c88edb9f90adc36ec65b90393fdd08d288d9843995fdfd27c4f3d9fdca9e6774400199b6189b05f0dd2fea6ce228e3d07c01
|
7
|
+
data.tar.gz: 50b0cb09fc6387118b0e731dd4a4945fde6d3c5946dedbd8ece55b10e4f8fdcf27f0a1933cdf207121629e09d2d4a1e7d20c721a51914b44af9402ecb0ec0d0d
|
data/CHANGELOG.md
CHANGED
data/lib/auth/lh/version.rb
CHANGED
data/lib/auth/lh.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'auth_lh'
|
2
|
+
require 'auth_lh/authentication'
|
2
3
|
require 'auth_lh/external_app'
|
3
4
|
require 'auth_lh/login_attempt'
|
4
5
|
require 'auth_lh/session_response'
|
@@ -9,3 +10,4 @@ require 'auth/lh/version'
|
|
9
10
|
# dependencies
|
10
11
|
require 'rest-client'
|
11
12
|
require 'singleton'
|
13
|
+
require 'time'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module AuthLh
|
2
|
+
module Authentication
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
def auth_user
|
8
|
+
if @auth_user.nil?
|
9
|
+
@auth_user = self.class.find_external(login)
|
10
|
+
end
|
11
|
+
|
12
|
+
@auth_user
|
13
|
+
end
|
14
|
+
|
15
|
+
def auth_user=(val)
|
16
|
+
@auth_user = val
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
def all_external
|
21
|
+
unless @cache_auth_users
|
22
|
+
@cache_auth_users = AuthLh.get_users
|
23
|
+
end
|
24
|
+
|
25
|
+
@cache_auth_users
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_external(login)
|
29
|
+
all_external.find { |x| x.login == login.to_s }
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_logged_user(session_token, remote_ip)
|
33
|
+
if (session_token.present? && (@session_token != session_token))
|
34
|
+
response = AuthLh.logged_user(session_token, remote_ip)
|
35
|
+
|
36
|
+
if response.nil?
|
37
|
+
@cached_logged_user = nil
|
38
|
+
@session_token = nil
|
39
|
+
@login_error = nil
|
40
|
+
else
|
41
|
+
@cached_logged_user = response.user
|
42
|
+
@session_token = session_token
|
43
|
+
@login_error = response.reason
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if @cached_logged_user
|
48
|
+
user = find_or_create_by(login: @cached_logged_user.login)
|
49
|
+
user.auth_user = @cached_logged_user
|
50
|
+
user
|
51
|
+
else
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def login_url
|
57
|
+
if @login_error
|
58
|
+
"#{AuthLh.login_url}&reason=#{@login_error}"
|
59
|
+
else
|
60
|
+
AuthLh.login_url
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def logout_url
|
65
|
+
AuthLh.logout_url
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auth-lh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias Hick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/auth/lh.rb
|
66
66
|
- lib/auth/lh/version.rb
|
67
67
|
- lib/auth_lh.rb
|
68
|
+
- lib/auth_lh/authentication.rb
|
68
69
|
- lib/auth_lh/external_app.rb
|
69
70
|
- lib/auth_lh/login_attempt.rb
|
70
71
|
- lib/auth_lh/session_response.rb
|
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.2.
|
93
|
+
rubygems_version: 2.2.2
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: Authentication with auth lh api
|