cognito_idp_rails 0.1.0 → 1.0.0

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: f89e3021ee553c158133054d9b09a94fe02a0b0a490b462947a2b974df4cc0a9
4
- data.tar.gz: 4984a4e7baffdce01541c67295575ba6dc518c53c94d66854dce6d51eabe494e
3
+ metadata.gz: f2e90ec3ceff76f7525a0cb71ab3f0457fef60d32cfe41fe5d4f27a3a2b0e916
4
+ data.tar.gz: 62218081d1ebd666aa06280a31b2e2ae8a587a3abe5858b086bcabaebdc6aaf2
5
5
  SHA512:
6
- metadata.gz: 5df85e9025803085b8aabb27a7b389219e87b6d817744ff7045f3075e1eef54b468288f387d559164d895faee2d34a9f17d78a43d8238f8b59e86d7dfe5ee40f
7
- data.tar.gz: 85bc14d48e72a38fee9ffdc11e0fbcd3768a39aaebcb8c0fbd45076c26bb254ec01dc006d3556f9e652b7a401bd993e4823fe40771f75d826c87cf68bbf43222
6
+ metadata.gz: '0793b32cdb97929f1cc53a49a51b087efb6a9053e380e4aae97ba58b42310a86227fe87f82bd5e3a25d1e668499ad0643519d470cf24761ef6a12355adeff9c1'
7
+ data.tar.gz: 34e1e1c5930521393a61c4ed1b04da405035d8c58b6f8da845db1c871a87237ded53b4d2fddd9a0dfc17d7dc4c912f107618f82925b12edefc42090f22daf534
data/README.md CHANGED
@@ -16,12 +16,12 @@ If bundler is not being used to manage dependencies, install the gem by executin
16
16
 
17
17
  After adding the gem to your application, run the install generator:
18
18
 
19
- $ rails generate cognito_idp:install
19
+ $ rails generate cognito_idp_rails:install
20
20
 
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 `on_valid_login` function in the initializer appropriate for any actions you
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
data/Rakefile CHANGED
@@ -6,3 +6,10 @@ load "rails/tasks/engine.rake"
6
6
  load "rails/tasks/statistics.rake"
7
7
 
8
8
  require "bundler/gem_tasks"
9
+ require "rspec/core/rake_task"
10
+
11
+ RSpec::Core::RakeTask.new(:spec)
12
+
13
+ require "standard/rake"
14
+
15
+ task default: %i[spec standard]
@@ -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.on_valid_login.call(token, user_info, session)
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.on_logout.call(session)
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, :on_logout, :on_valid_login, :scope
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
- @on_valid_login = lambda { |token, user_info, session| }
10
- @on_logout = lambda { |session| }
9
+ @after_login = lambda { |token, user_info, request| }
10
+ @before_logout = lambda { |request| }
11
11
  end
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module CognitoIdpRails
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  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.on_valid_login = lambda do |token, user_info, session|
5
+ config.after_login = lambda do |token, user_info, request|
6
6
  # 1. Find or create a user.
7
- # user = User.where(identifier: user_info.sub).find_or_create do |user|
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.on_logout = lambda do |session|
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.1.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-07 00:00:00.000000000 Z
11
+ date: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cognito_idp
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: '0'
85
+ version: 2.6.0
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="