wordjelly-auth 1.5.2 → 1.5.3

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: 7a1e6306f00703dc564bdd7b3d677c814d7a85c4f3fe3aa905b05d6d8cd9e591
4
- data.tar.gz: c94b1bae40c2694a3b9b2b2d4acdef709a7479a37726bd7e10531819573ffc3d
3
+ metadata.gz: f71e0dcebda1f38fdaab81b8f16b2336be897de9d09c544d11177b563ef3e86f
4
+ data.tar.gz: 7bd8cd9bbfe27efc9d4da172b1a45e0e5d0966e76d9dc45d88a300b31a7992a4
5
5
  SHA512:
6
- metadata.gz: a20525f63400e60abbc65f48362dd54808e4d1e709f31a9a3e97b6c462d327aaec4d82d9acd5637e158c6b0e8667bccecea89918736bfd875704bdc7d0af7961
7
- data.tar.gz: e2b104327ea59b20f8b0f1d85d732c50796991e1bda7a34d8e00b32e409da5a6a4cdecf3736ca8a3a81d24fea9de3272796ffbe7bf07894c982787ad78d2a10a
6
+ metadata.gz: 97d49ac10bc8898169880557974f72481ae117043e3d09bf5b2087dc1534676f44fc342fa91f3bdc1723f04d2cb8b7aa25d931f87d4c32aa255420c1ae293856
7
+ data.tar.gz: acaa921dbd21a004f863c6c51fd24e95bf457cef6342d56c6086bbf6d1215c7252259e17ae9a0fd12e241e5dd19fb4acd0ffde935a16f6193a5e297cc8621784
@@ -385,14 +385,80 @@ end
385
385
 
386
386
  module SimpleTokenAuthentication
387
387
  module Configuration
388
+
388
389
  mattr_accessor :additional_identifiers
390
+
391
+ =begin
392
+ ########################################################
393
+ ##
394
+ ##
395
+ ## STRUCTURE
396
+ ##
397
+ ##
398
+ ########################################################
399
+ {
400
+ "controllers" :
401
+ {
402
+ "controller_name(demodularized)" : {
403
+ "actions" : [
404
+ {
405
+ "action_name" : "new",
406
+ "requires_authentication" : "yes",
407
+ "requires_authorization" : "no"
408
+ },
409
+ ]
410
+ }
411
+ }
412
+ }
413
+ =end
414
+ mattr_accessor :permissions
415
+
389
416
  @@additional_identifiers = {}
417
+ @@permissions = {}
418
+
390
419
  end
391
420
 
392
421
  ## had to include option force true because otherwise devise does not throw a 401 if you try to do token_authentication inside a devise controller.
393
422
  ## took 3 hours to sort this mess out.
394
423
  DeviseFallbackHandler.class_eval do
395
424
 
425
+ def permit_unauthenticated?(controller)
426
+ unless SimpleTokenAuthentication.permissions.blank?
427
+ unless SimpleTokenAuthentication.permissions["controllers"].blank?
428
+ unless SimpleTokenAuthentication.permissions["controllers"][controller.controller_name].blank?
429
+ unless SimpleTokenAuthentication.permissions["controllers"][controller.controller_name]["actions"].blank?
430
+
431
+ current_action = SimpleTokenAuthentication.permissions["controllers"][controller.controller_name]["actions"].select{|c|
432
+
433
+ c["action_name"] == controller.action_name
434
+
435
+ }
436
+
437
+ puts "the current action is:"
438
+ puts current_action.to_s
439
+
440
+ unless current_action.blank?
441
+
442
+ ## so if requires authentication is either "optional" or "no", it will not fallback onto devise, and let the thing pass through.
443
+ ## this has to be set in the initializers.
444
+
445
+ return current_action[0]["requires_authentication"] != "yes"
446
+
447
+ end
448
+
449
+ end
450
+ end
451
+ end
452
+ end
453
+ false
454
+ end
455
+
456
+ def fallback!(controller, entity)
457
+ unless permit_unauthenticated?(controller)
458
+ authenticate_entity!(controller, entity)
459
+ end
460
+ end
461
+
396
462
  def authenticate_entity!(controller, entity)
397
463
  controller.send("authenticate_#{entity.name_underscore}!".to_sym,{:force => true})
398
464
  end
@@ -432,7 +498,11 @@ module SimpleTokenAuthentication
432
498
  ## so we will have to mod this to check for an accessor.
433
499
  ## otherwise it will screw up totally.
434
500
  def ensure_authentication_token
501
+
502
+ puts "the skip authentication token is: #{self.skip_authentication_token_regeneration}"
503
+
435
504
  regenerate_token if self.skip_authentication_token_regeneration.blank?
505
+
436
506
  end
437
507
  end
438
508
 
@@ -468,6 +538,7 @@ module SimpleTokenAuthentication
468
538
  ##then we should find
469
539
 
470
540
  record = find_record_from_identifier(entity)
541
+ #puts "-------------!!!-----------!!!!"
471
542
  #puts "record found is: #{record.to_s}"
472
543
 
473
544
  if token_correct?(record, entity, token_comparator)
@@ -502,7 +573,7 @@ module SimpleTokenAuthentication
502
573
  if token
503
574
 
504
575
  ## fails if the app id or user es is nil blank or empty
505
- #puts "returning nil"
576
+
506
577
  #puts "app id vlue is:"
507
578
  #puts app_id_value.to_s
508
579
  #puts "user es value is:"
@@ -533,7 +604,7 @@ module SimpleTokenAuthentication
533
604
 
534
605
  if records.size > 0
535
606
  #puts "the records size is:"
536
- ##puts records.size.to_s
607
+ #puts records.size.to_s
537
608
  #puts "found such a record.!!!!!!!!!!!!"
538
609
  r = records.first
539
610
  #puts r.attributes.to_s
@@ -546,8 +617,14 @@ module SimpleTokenAuthentication
546
617
  end
547
618
 
548
619
  def token_correct?(record, entity, token_comparator)
620
+ #puts "record is----------------------------000-0-0-0-0-0-0-0-0-:"
621
+ #puts record.to_s
549
622
  return false unless record
550
623
  token = entity.get_token_from_params_or_headers(self)
624
+ #puts "token from headers is: #{token}"
625
+ #puts "the encrypted authentication token:"
626
+ #puts record.encrypted_authentication_token.to_s
627
+
551
628
  Devise::Encryptor.compare(record.class,record.encrypted_authentication_token,token)
552
629
  end
553
630
  end
data/lib/auth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Auth
2
- VERSION = "1.5.2"
2
+ VERSION = "1.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordjelly-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bhargav
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
11
+ date: 2019-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk