lockie 0.2.12 → 0.3.1
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/README.md +5 -4
- data/lib/lockie.rb +2 -0
- data/lib/lockie/controller_helper.rb +2 -0
- data/lib/lockie/failure_app.rb +2 -2
- data/lib/lockie/rails.rb +17 -3
- data/lib/lockie/version.rb +1 -1
- metadata +6 -7
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4891f7485ad02efb026b823bc53c1975f05661eca97414310fdf89a93305188d
         | 
| 4 | 
            +
              data.tar.gz: 4ba661f6c8e3e40415695f9fecd2fe7fb7e3d9d2ef5542af7420792575c7d399
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a1d92c0e6f02c98dcd46adc5fdb9559e9593f7c6f90f513eca1569d00ea77fa14c6b58afa41470806477b57bb786b191cd9e29d5fd3e9b1dbdd351bc46186f16
         | 
| 7 | 
            +
              data.tar.gz: 70ae39adb0997816279aac2880cdc274dd1b2e1e253ac4008aa7bcd0cd50348fc1a6ac2731c9714c96a9a857b0a04e5f62ddfb976052393f739e464a2960a5b6
         | 
    
        data/README.md
    CHANGED
    
    | @@ -9,7 +9,7 @@ A drop-in, none assuming warden based Password and JWT authentication for Rails | |
| 9 9 | 
             
            Add this line to your application's Gemfile:
         | 
| 10 10 |  | 
| 11 11 | 
             
            ```ruby
         | 
| 12 | 
            -
            gem 'lockie', '~> 0. | 
| 12 | 
            +
            gem 'lockie', '~> 0.3.1'
         | 
| 13 13 | 
             
            ```
         | 
| 14 14 |  | 
| 15 15 | 
             
            And then execute:
         | 
| @@ -89,7 +89,8 @@ Lockie.configure do |c| | |
| 89 89 | 
             
              # set custom scopes
         | 
| 90 90 | 
             
              c.scopes = [
         | 
| 91 91 | 
             
                [:api, { store: false, strategies: [:jwt]}],
         | 
| 92 | 
            -
                [:web, { store: true, strategies: [:email_password]}]
         | 
| 92 | 
            +
                [:web, { store: true, strategies: [:email_password]}],
         | 
| 93 | 
            +
                [:admin, { store: true, strategies: [:email_password], unauthenticated_path: "/login-admin" }]
         | 
| 93 94 | 
             
              ]
         | 
| 94 95 | 
             
            end
         | 
| 95 96 | 
             
            ```
         | 
| @@ -101,12 +102,12 @@ Using `Warden::Test::Helpers` https://github.com/wardencommunity/warden/wiki/tes | |
| 101 102 | 
             
            ```
         | 
| 102 103 | 
             
            include Warden::Test::Helpers
         | 
| 103 104 |  | 
| 104 | 
            -
             | 
| 105 | 
            +
            setup do
         | 
| 105 106 | 
             
              @user = users(:one)
         | 
| 106 107 | 
             
              login_as @user
         | 
| 107 108 |  | 
| 108 109 | 
             
            end
         | 
| 109 | 
            -
             | 
| 110 | 
            +
            teardown { Warden.test_reset! }
         | 
| 110 111 | 
             
            ```
         | 
| 111 112 |  | 
| 112 113 | 
             
            ### Testing JSON Api with token
         | 
    
        data/lib/lockie.rb
    CHANGED
    
    | @@ -21,6 +21,7 @@ module Lockie | |
| 21 21 | 
             
                attr_accessor :callback_url
         | 
| 22 22 | 
             
                attr_accessor :scopes
         | 
| 23 23 | 
             
                attr_accessor :serializer_to_session, :serializer_from_session
         | 
| 24 | 
            +
                attr_accessor :session_timeout
         | 
| 24 25 |  | 
| 25 26 | 
             
                def initialize
         | 
| 26 27 | 
             
                  @model_name = "User"
         | 
| @@ -32,6 +33,7 @@ module Lockie | |
| 32 33 | 
             
                  @scopes = []
         | 
| 33 34 | 
             
                  @serializer_to_session = nil
         | 
| 34 35 | 
             
                  @serializer_from_session = nil
         | 
| 36 | 
            +
                  @session_timeout = 3.hours
         | 
| 35 37 | 
             
                end
         | 
| 36 38 | 
             
              end
         | 
| 37 39 |  | 
    
        data/lib/lockie/failure_app.rb
    CHANGED
    
    | @@ -35,7 +35,7 @@ module Lockie | |
| 35 35 | 
             
                  self.status = 302
         | 
| 36 36 | 
             
                  if Lockie.config.callback_url
         | 
| 37 37 | 
             
                    callback_url = request.base_url + request.original_fullpath
         | 
| 38 | 
            -
                    uri = URI(Lockie.config.unauthenticated_path)
         | 
| 38 | 
            +
                    uri = URI(warden_options[:unauthenticated_path] || Lockie.config.unauthenticated_path)
         | 
| 39 39 | 
             
                    uri.query = (uri.query.to_s.split("&") << "callback_url=#{ callback_url }").join("&")
         | 
| 40 40 | 
             
                    redirect_to uri.to_s
         | 
| 41 41 | 
             
                  else
         | 
| @@ -56,7 +56,7 @@ module Lockie | |
| 56 56 | 
             
                end
         | 
| 57 57 |  | 
| 58 58 | 
             
                def warden
         | 
| 59 | 
            -
                  env['warden']
         | 
| 59 | 
            +
                  request.env['warden']
         | 
| 60 60 | 
             
                end
         | 
| 61 61 |  | 
| 62 62 | 
             
              end
         | 
    
        data/lib/lockie/rails.rb
    CHANGED
    
    | @@ -8,19 +8,33 @@ module Lockie | |
| 8 8 | 
             
                    manager.failure_app = Lockie::FailureApp
         | 
| 9 9 |  | 
| 10 10 | 
             
                    if Lockie.config.serialize_session
         | 
| 11 | 
            -
                      serializer_to_session = Lockie.config.serializer_to_session || proc { |u| u. | 
| 11 | 
            +
                      serializer_to_session = Lockie.config.serializer_to_session || proc { |u| [u.class.name, u.id] }
         | 
| 12 12 | 
             
                      manager.serialize_into_session(&serializer_to_session)
         | 
| 13 | 
            -
                      serializer_from_session = Lockie.config.serializer_from_session || proc { | | 
| 13 | 
            +
                      serializer_from_session = Lockie.config.serializer_from_session || proc { |s| s.first.constantize.find(s.last) }
         | 
| 14 14 | 
             
                      manager.serialize_from_session(&serializer_from_session)
         | 
| 15 15 | 
             
                    end
         | 
| 16 16 |  | 
| 17 17 | 
             
                    Lockie.config.scopes.each do |scope|
         | 
| 18 | 
            -
                      manager.scope_defaults | 
| 18 | 
            +
                      manager.scope_defaults(*scope)
         | 
| 19 19 | 
             
                    end
         | 
| 20 20 |  | 
| 21 21 | 
             
                  end
         | 
| 22 22 | 
             
              end
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            +
            Warden::Manager.after_authentication do |record, warden, options|
         | 
| 26 | 
            +
              session_key = "warden.uls-#{record.class.name.underscore}-#{record.id}"
         | 
| 27 | 
            +
              warden.request.session[session_key] = (Time.now + Lockie.config.session_timeout).to_s
         | 
| 28 | 
            +
            end
         | 
| 29 | 
            +
             | 
| 25 30 | 
             
            Warden::Manager.after_set_user do |record, warden, options|
         | 
| 31 | 
            +
              session_key = "warden.uls-#{record.class.name.underscore}-#{record.id}"
         | 
| 32 | 
            +
              last_session_access = warden.request.session[session_key]
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              if last_session_access && Time.parse(last_session_access) < Time.now
         | 
| 35 | 
            +
                # session expired
         | 
| 36 | 
            +
                warden.logout
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              warden.request.session[session_key] = Time.now + Lockie.config.session_timeout
         | 
| 26 40 | 
             
            end
         | 
    
        data/lib/lockie/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: lockie
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Melvin Sembrano
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-08-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -81,19 +81,19 @@ dependencies: | |
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: 3.1.7
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            -
              name:  | 
| 84 | 
            +
              name: byebug
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 86 | 
             
                requirements:
         | 
| 87 87 | 
             
                - - "~>"
         | 
| 88 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            -
                    version:  | 
| 89 | 
            +
                    version: 11.1.3
         | 
| 90 90 | 
             
              type: :development
         | 
| 91 91 | 
             
              prerelease: false
         | 
| 92 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 93 | 
             
                requirements:
         | 
| 94 94 | 
             
                - - "~>"
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version:  | 
| 96 | 
            +
                    version: 11.1.3
         | 
| 97 97 | 
             
            description: Drop in password and JWT token authentication for Ruby on Rails
         | 
| 98 98 | 
             
            email:
         | 
| 99 99 | 
             
            - melvinsembrano@gmail.com
         | 
| @@ -135,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 135 135 | 
             
                - !ruby/object:Gem::Version
         | 
| 136 136 | 
             
                  version: '0'
         | 
| 137 137 | 
             
            requirements: []
         | 
| 138 | 
            -
             | 
| 139 | 
            -
            rubygems_version: 2.7.7
         | 
| 138 | 
            +
            rubygems_version: 3.0.8
         | 
| 140 139 | 
             
            signing_key: 
         | 
| 141 140 | 
             
            specification_version: 4
         | 
| 142 141 | 
             
            summary: Drop in password and JWT token authentication for Ruby on Rails
         |