cognito_idp_rails 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/cognito_idp_rails/sessions_controller.rb +2 -2
- data/lib/cognito_idp_rails/configuration.rb +3 -3
- data/lib/cognito_idp_rails/version.rb +1 -1
- data/lib/generators/cognito_idp_rails/templates/cognito_idp_rails_initializer.rb.tt +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2e90ec3ceff76f7525a0cb71ab3f0457fef60d32cfe41fe5d4f27a3a2b0e916
|
4
|
+
data.tar.gz: 62218081d1ebd666aa06280a31b2e2ae8a587a3abe5858b086bcabaebdc6aaf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0793b32cdb97929f1cc53a49a51b087efb6a9053e380e4aae97ba58b42310a86227fe87f82bd5e3a25d1e668499ad0643519d470cf24761ef6a12355adeff9c1'
|
7
|
+
data.tar.gz: 34e1e1c5930521393a61c4ed1b04da405035d8c58b6f8da845db1c871a87237ded53b4d2fddd9a0dfc17d7dc4c912f107618f82925b12edefc42090f22daf534
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ After adding the gem to your application, run the install generator:
|
|
21
21
|
This generator will add `cognito_idp` to your routes and install an initializer at `config/initializers/cognito_idp.rb`.
|
22
22
|
|
23
23
|
Be sure to review and edit the initializer to configure options for your Amazon Cognito User Pool configuration. You
|
24
|
-
must also provide an implementation for the `
|
24
|
+
must also provide an implementation for the `after_login` function in the initializer appropriate for any actions you
|
25
25
|
want to take when a user signed in.
|
26
26
|
|
27
27
|
## Development
|
@@ -12,7 +12,7 @@ module CognitoIdpRails
|
|
12
12
|
client.get_token(grant_type: :authorization_code, code: params[:code], redirect_uri: auth_login_callback_url) do |token|
|
13
13
|
client.get_user_info(token) do |user_info|
|
14
14
|
reset_session
|
15
|
-
configuration.
|
15
|
+
configuration.after_login.call(token, user_info, request)
|
16
16
|
redirect_to configuration.after_login_route, notice: "You have been successfully logged in."
|
17
17
|
return
|
18
18
|
end
|
@@ -25,7 +25,7 @@ module CognitoIdpRails
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def logout_callback
|
28
|
-
configuration.
|
28
|
+
configuration.before_logout.call(request)
|
29
29
|
reset_session
|
30
30
|
redirect_to configuration.after_logout_route, notice: "You have been successfully logged out."
|
31
31
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module CognitoIdpRails
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :after_login_route, :after_logout_route, :domain, :client_id,
|
4
|
-
:client_secret, :
|
4
|
+
:client_secret, :after_login, :before_logout, :scope
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@after_login_route = "/"
|
8
8
|
@after_logout_route = "/"
|
9
|
-
@
|
10
|
-
@
|
9
|
+
@after_login = lambda { |token, user_info, request| }
|
10
|
+
@before_logout = lambda { |request| }
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -2,16 +2,16 @@ CognitoIdpRails.configure do |config|
|
|
2
2
|
config.client_id = ENV["COGNITO_CLIENT_ID"]
|
3
3
|
config.client_secret = ENV["COGNITO_CLIENT_SECRET"]
|
4
4
|
config.domain = ENV["COGNITO_DOMAIN"]
|
5
|
-
config.
|
5
|
+
config.after_login = lambda do |token, user_info, request|
|
6
6
|
# 1. Find or create a user.
|
7
7
|
# user = User.where(identifier: user_info.sub).first_or_create do |user|
|
8
8
|
# user.email = user_info.email
|
9
9
|
# end
|
10
10
|
|
11
11
|
# 2. Set any session data for the user.
|
12
|
-
# session[:user_id] = user.id
|
12
|
+
# request.session[:user_id] = user.id
|
13
13
|
end
|
14
|
-
config.
|
14
|
+
config.before_logout = lambda do |request|
|
15
15
|
# Your last chance to do something before the session is reset.
|
16
16
|
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cognito_idp_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Hatherall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cognito_idp
|