openam_auth 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openam_auth/authenticate.rb +35 -32
- data/lib/openam_auth/openam.rb +0 -2
- data/lib/openam_auth/version.rb +1 -1
- data/lib/openam_auth.rb +1 -0
- data/spec/openam_auth_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0913734338ee45a826e3d2b8b2d060c405532105
|
4
|
+
data.tar.gz: 79dbfc448da870664023029b11fbe2413b69ee7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3504d9e01a6a22a669dc5c00b0d9d4a73230a489893fce6f89f34726e328ef2a58dd87398f071048f4aad387a16e99b4a6c5ddb3fc788a6540d992815c619a4d
|
7
|
+
data.tar.gz: 1a92e5e78da602b5f8147354833540c53a0105dfa11483e465768ff6175982e7e8ac86b64cf7d05ef5bcaf7a2b477e0cca89deeccc8753ef61a613b337379295
|
@@ -1,45 +1,48 @@
|
|
1
1
|
module OpenamAuth
|
2
2
|
module Authenticate
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#The following class method shold be implemented by the parent application
|
14
|
-
user = User.existing_user_by_token(token) if token
|
15
|
-
|
16
|
-
unless user
|
17
|
-
if openam.valid_token?(token)
|
18
|
-
response = openam.openam_user(cookie_name, token)
|
19
|
-
user_hash = openam.user_hash(response.body)
|
20
|
-
#following class method should be implemented by the parent application
|
21
|
-
user = User.update_openam_user(token, user_hash)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
if user
|
25
|
-
session[:user_id] = user.id
|
26
|
-
status = true
|
27
|
-
end
|
28
|
-
status ? true : (redirect_to openam.login_url)
|
29
|
-
end
|
3
|
+
attr_accessor :openam_instance
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def authenticate_user!
|
7
|
+
user ||= User.update_openam_user(token, user_hash) if openam.valid_token?(token)
|
8
|
+
|
9
|
+
session[:user_id] = user.id if user
|
10
|
+
|
11
|
+
!!session[:user_id] || redirect_to(openam.login_url)
|
30
12
|
end
|
31
13
|
|
32
|
-
|
33
|
-
|
14
|
+
private
|
15
|
+
def openam
|
16
|
+
@openam_instance ||= OpenamAuth::Openam.new
|
17
|
+
@openam_instance
|
18
|
+
end
|
19
|
+
|
20
|
+
def cookie_name
|
21
|
+
openam.cookie_name
|
22
|
+
end
|
23
|
+
|
24
|
+
def token
|
25
|
+
openam.token_cookie(request, cookie_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def user
|
29
|
+
User.existing_user_by_token(token)
|
34
30
|
end
|
35
31
|
|
36
32
|
def current_user
|
37
33
|
User.where(id: session[:user_id]).first
|
38
34
|
end
|
39
35
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
36
|
+
def user_hash
|
37
|
+
openam.user_hash(openam_response.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
def openam_response
|
41
|
+
openam.openam_user(cookie_name, token)
|
42
|
+
end
|
43
|
+
|
44
|
+
def openam_logout(token)
|
45
|
+
openam.new.logout(token)
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
data/lib/openam_auth/openam.rb
CHANGED
data/lib/openam_auth/version.rb
CHANGED
data/lib/openam_auth.rb
CHANGED
data/spec/openam_auth_spec.rb
CHANGED
@@ -47,7 +47,7 @@ EOF
|
|
47
47
|
to_return(:status => 200, :body => response, :headers => {})
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
fit "should return openam user string" do
|
51
51
|
OpenamAuth::Openam.new.openam_user('iPlanetDirectoryPro',token).to_s.should eq(response)
|
52
52
|
end
|
53
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openam_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sameera207
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|