snuffleupagus 0.1.1 → 0.1.2
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/CHANGELOG.md +4 -0
 - data/lib/snuffleupagus/auth_token.rb +2 -2
 - data/lib/snuffleupagus/version.rb +1 -1
 - data/spec/snuffleupagus_spec.rb +5 -5
 - 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: 78ba5652942ab4bb945ced5e32696f91a5ca32133294f255ed22e6dc7c7ba5a5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f583416e9b741ee77d84de3f0cdcf0f5df5c71648b3156ee5f2bb0531b77426c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 25c0f294acc08273c4fc62cb203c73fdb539df5d888649a0af985e8d08042b61d755dcf63a31f27b987f85f5fd3cd42ada3e013c366e3f3da008e020a19c284d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9f01b85aa3dc12dbd4b309773df728386a88dd19649a638b7b5ecbbe7049a6e16dc2970cd7cc2a0ef47030e0b754ddde29dd5d5f1236d2416c42ef2548632add
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -3,6 +3,10 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            ## Unreleased
         
     | 
| 
       4 
4 
     | 
    
         
             
            - none
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
            ## [0.1.1](releases/tag/v0.1.1) - 2020-10-21
         
     | 
| 
      
 7 
     | 
    
         
            +
            ### Updated
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Use named parameters when creating and validating tokens
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       6 
10 
     | 
    
         
             
            ## [0.1.1](releases/tag/v0.1.1) - 2020-10-21
         
     | 
| 
       7 
11 
     | 
    
         
             
            ### Added
         
     | 
| 
       8 
12 
     | 
    
         
             
            - Add context to the create/check token to avoid replay in different contexts
         
     | 
| 
         @@ -27,11 +27,11 @@ module Snuffleupagus 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  @cipher = OpenSSL::Cipher.new('aes-256-cbc')
         
     | 
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
                def create_token(context)
         
     | 
| 
      
 30 
     | 
    
         
            +
                def create_token(context:)
         
     | 
| 
       31 
31 
     | 
    
         
             
                  encode encrypt "#{CONSTANT}#{context}#{Time.now.to_i}"
         
     | 
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                def token_valid?(token 
     | 
| 
      
 34 
     | 
    
         
            +
                def token_valid?(token:, context:)
         
     | 
| 
       35 
35 
     | 
    
         
             
                  return false unless token.is_a? String
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                  decoded = decrypt decode token
         
     | 
    
        data/spec/snuffleupagus_spec.rb
    CHANGED
    
    | 
         @@ -7,7 +7,7 @@ describe Snuffleupagus::AuthToken do 
     | 
|
| 
       7 
7 
     | 
    
         
             
              let(:snuffy) { Snuffleupagus::AuthToken.new('sup3r4w3s0m3p4ssw0rd') }
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              describe '#create_token' do
         
     | 
| 
       10 
     | 
    
         
            -
                subject { snuffy.create_token 'my-context' }
         
     | 
| 
      
 10 
     | 
    
         
            +
                subject { snuffy.create_token context: 'my-context' }
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                it { is_expected.to be_a String }
         
     | 
| 
       13 
13 
     | 
    
         
             
                it { expect(subject.length).to eq 96 }
         
     | 
| 
         @@ -15,16 +15,16 @@ describe Snuffleupagus::AuthToken do 
     | 
|
| 
       15 
15 
     | 
    
         
             
              end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
              describe '#token_valid?' do
         
     | 
| 
       18 
     | 
    
         
            -
                subject { snuffy.token_valid?(token, 'my-context') }
         
     | 
| 
      
 18 
     | 
    
         
            +
                subject { snuffy.token_valid?(token: token, context: 'my-context') }
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                context 'with a valid token' do
         
     | 
| 
       21 
     | 
    
         
            -
                  let(:token) { snuffy.create_token 'my-context' }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  let(:token) { snuffy.create_token context: 'my-context' }
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                  it { is_expected.to be_truthy }
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                context 'when the context doesnt match' do
         
     | 
| 
       27 
     | 
    
         
            -
                  let(:token) { snuffy.create_token 'another-context' }
         
     | 
| 
      
 27 
     | 
    
         
            +
                  let(:token) { snuffy.create_token context: 'another-context' }
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                  it { is_expected.to be_falsey }
         
     | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
         @@ -48,7 +48,7 @@ describe Snuffleupagus::AuthToken do 
     | 
|
| 
       48 
48 
     | 
    
         
             
                end
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
       50 
50 
     | 
    
         
             
                context 'testing expired tokens' do
         
     | 
| 
       51 
     | 
    
         
            -
                  let(:token) { snuffy.create_token 'my-context' }
         
     | 
| 
      
 51 
     | 
    
         
            +
                  let(:token) { snuffy.create_token context: 'my-context' }
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
                  before { token } # pre-load the token
         
     | 
| 
       54 
54 
     | 
    
         
             
                  after { Timecop.return }
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: snuffleupagus
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrew Bromwich
         
     | 
| 
         @@ -116,5 +116,5 @@ requirements: [] 
     | 
|
| 
       116 
116 
     | 
    
         
             
            rubygems_version: 3.0.6
         
     | 
| 
       117 
117 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       118 
118 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       119 
     | 
    
         
            -
            summary: snuffleupagus-0.1. 
     | 
| 
      
 119 
     | 
    
         
            +
            summary: snuffleupagus-0.1.2
         
     | 
| 
       120 
120 
     | 
    
         
             
            test_files: []
         
     |