go_sso 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94692c360a28d7beff1f95900b6b798d2bee7a554e988f003623ed8675969751
4
- data.tar.gz: 63990eb7c21d4f8d4316d143abad2596a9533b43576021e00b441595664b076b
3
+ metadata.gz: 141663866cb0c76ce7d600625d230153c747493dd4814ad5dd3a79e7d8cd8846
4
+ data.tar.gz: 686176927a42cd377a4dc38bc9eca2125c812b70366b695603187365a58bc2ce
5
5
  SHA512:
6
- metadata.gz: eb726512139fcae3835d644f31304ae509509eefab7a19bcdba264eba04601ea76bc3d4b674480ceead8757e0a9d9bbdd0bc21b5654011c2fa4fcea6c4c78da7
7
- data.tar.gz: f77a159bf650f9a855a059cbb416954b22a39d96a76477834fbd88b1f8584e1a454ce7126662751c8796d592e40bd1f71d9ce9a56294696b8dcfe9c7947057cb
6
+ metadata.gz: 92ebdb0a8e6ad0a81de62f66c15cd6891b1dc836a88203a1c3c251de604e3499a249f160b74937c0d3d6782144b15bfe5dd066d76cf15e93f49d982a2343a800
7
+ data.tar.gz: c42f320ed2432412fe15ac7415f7b8d52f82a5f4a417d78ff76c6f6d3c5d2191b3d5e8edc88eb3fcb7f2147635cd14fef9abc8e2b15aa526a3ecbea126125bea
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # GoSSO
2
+
3
+ This is a plugin to protect applications from access by unauthorized users.
4
+ You need to have your own OAuth server as SSO(Single Sign On) server
5
+ then install this plugin to each application need to be protected.
6
+
7
+ Set the SSO server secrets through environment variables:
8
+ ```
9
+ GO_SSO_CLIENT_ID=
10
+ GO_SSO_CLIENT_SECRET=
11
+ GO_SSO_CLIENT_SITE=
12
+ ```
13
+
14
+ Create a initializer file for other configurations:
15
+
16
+ ```
17
+ GoSso.setup do |config|
18
+ config.client_id # GO_SSO_CLIENT_ID
19
+ config.client_secret # GO_SSO_CLIENT_SECRET
20
+ config.site # GO_SSO_CLIENT_SITE
21
+ config.user_json_url # default: 'api/me'
22
+ config.user_cache_ttl # default 1.minute
23
+ config.main_app_module_name # default is your host app module name
24
+ config.host # set to your app host
25
+ end
26
+ ```
27
+
28
+ You must implement `api/me` to response user information in JSON format which provides `applications` attribute at least.
29
+ `applications` is an array of strings.
30
+
31
+ Add `before :authenticate_sso_user_permission` to application controllers.
32
+ Pages with this hook will be protected.
33
+ If `current_sso_user` is not present, redirect users to SSO to login.
34
+ Users can access the protected page only if after login and their applications attribute contains `main_app_module_name`
35
+
36
+ You can access current user in views or controllers via `current_sso_user`.
@@ -36,9 +36,5 @@ module GoSso
36
36
  session[:go_sso_token] = session[:go_sso_token_expires_at] = nil
37
37
  end
38
38
  end
39
-
40
- def sso_token_expired?
41
- session[:go_sso_token_expires_at] < Time.now.to_i
42
- end
43
39
  end
44
40
  end
@@ -32,6 +32,10 @@ module GoSso
32
32
  render json: { message: 'access denied' }, status: 401
33
33
  end
34
34
  end
35
+
36
+ def sso_token_expired?
37
+ session[:go_sso_token_expires_at] < Time.now.to_i
38
+ end
35
39
  end
36
40
  end
37
41
  end
@@ -1,3 +1,3 @@
1
1
  module GoSso
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_sso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yi Feng
@@ -116,6 +116,7 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - MIT-LICENSE
119
+ - README.md
119
120
  - Rakefile
120
121
  - app/assets/config/go_sso_manifest.js
121
122
  - app/assets/stylesheets/go_sso/application.css