doorkeeper 0.1.1 → 0.2.0

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.

Potentially problematic release.


This version of doorkeeper might be problematic. Click here for more details.

Files changed (35) hide show
  1. data/README.md +42 -14
  2. data/Rakefile +1 -1
  3. data/app/assets/stylesheets/doorkeeper/application.css +4 -0
  4. data/app/controllers/doorkeeper/application_controller.rb +2 -2
  5. data/app/controllers/doorkeeper/application_controller.rbc +32 -20
  6. data/app/controllers/doorkeeper/authorizations_controller.rbc +86 -22
  7. data/app/controllers/doorkeeper/authorized_applications_controller.rb +13 -0
  8. data/app/controllers/doorkeeper/authorized_applications_controller.rbc +393 -0
  9. data/app/controllers/doorkeeper/tokens_controller.rb +4 -0
  10. data/app/models/access_grant.rb +8 -0
  11. data/app/models/access_grant.rbc +204 -39
  12. data/app/models/access_token.rb +31 -3
  13. data/app/models/access_token.rbc +270 -72
  14. data/app/models/application.rb +8 -1
  15. data/app/models/application.rbc +307 -61
  16. data/app/views/doorkeeper/authorizations/new.html.erb +17 -0
  17. data/app/views/doorkeeper/authorized_applications/index.html.erb +26 -0
  18. data/config/routes.rb +1 -0
  19. data/config/routes.rbc +48 -4
  20. data/lib/doorkeeper/config.rb +82 -22
  21. data/lib/doorkeeper/config.rbc +739 -295
  22. data/lib/doorkeeper/config/scope.rb +11 -0
  23. data/lib/doorkeeper/config/scopes.rb +57 -0
  24. data/lib/doorkeeper/config/scopes_builder.rb +18 -0
  25. data/lib/doorkeeper/doorkeeper_for.rb +96 -16
  26. data/lib/doorkeeper/oauth/access_token_request.rb +57 -18
  27. data/lib/doorkeeper/oauth/access_token_request.rbc +256 -67
  28. data/lib/doorkeeper/oauth/authorization_request.rb +31 -4
  29. data/lib/doorkeeper/oauth/authorization_request.rbc +230 -65
  30. data/lib/doorkeeper/version.rb +1 -1
  31. data/lib/doorkeeper/version.rbc +1 -1
  32. data/lib/generators/doorkeeper/templates/README +3 -0
  33. data/lib/generators/doorkeeper/templates/initializer.rb +13 -0
  34. data/lib/generators/doorkeeper/templates/migration.rb +4 -1
  35. metadata +35 -18
@@ -1,7 +1,7 @@
1
1
  class AccessToken < ActiveRecord::Base
2
2
  include Doorkeeper::OAuth::RandomString
3
3
 
4
- self.table_name = "oauth_access_tokens"
4
+ set_table_name :oauth_access_tokens
5
5
 
6
6
  belongs_to :application
7
7
 
@@ -9,9 +9,16 @@ class AccessToken < ActiveRecord::Base
9
9
 
10
10
  validates :application_id, :resource_owner_id, :token, :presence => true
11
11
 
12
+ attr_accessor :use_refresh_token
13
+
12
14
  before_validation :generate_token, :on => :create
15
+ before_validation :generate_refresh_token, :on => :create, :if => :use_refresh_token?
16
+
17
+ def self.authorized_for(application_id, resource_owner_id)
18
+ accessible.where(:application_id => application_id, :resource_owner_id => resource_owner_id).first
19
+ end
13
20
 
14
- def revoke!
21
+ def revoke
15
22
  update_attribute :revoked_at, DateTime.now
16
23
  end
17
24
 
@@ -20,15 +27,36 @@ class AccessToken < ActiveRecord::Base
20
27
  end
21
28
 
22
29
  def expired?
23
- self.expires_at.present? && DateTime.now > self.expires_at
30
+ expires_in.present? && Time.now > expired_time
24
31
  end
25
32
 
26
33
  def accessible?
27
34
  !expired? && !revoked?
28
35
  end
29
36
 
37
+ def scopes
38
+ scope_string = self[:scopes] || ""
39
+ scope_string.split(" ").map(&:to_sym)
40
+ end
41
+
42
+ def scopes_string
43
+ self[:scopes]
44
+ end
45
+
46
+ def use_refresh_token?
47
+ self.use_refresh_token
48
+ end
49
+
30
50
  private
31
51
 
52
+ def expired_time
53
+ self.created_at + expires_in.seconds
54
+ end
55
+
56
+ def generate_refresh_token
57
+ self.refresh_token = unique_random_string_for(:refresh_token)
58
+ end
59
+
32
60
  def generate_token
33
61
  self.token = unique_random_string_for(:token)
34
62
  end
@@ -78,7 +78,7 @@ x
78
78
  11
79
79
  AccessToken
80
80
  i
81
- 189
81
+ 209
82
82
  5
83
83
  66
84
84
  5
@@ -97,16 +97,11 @@ i
97
97
  5
98
98
  7
99
99
  5
100
- 64
101
- 13
102
- 18
103
- 2
104
100
  47
105
101
  49
106
102
  6
107
103
  1
108
104
  15
109
- 15
110
105
  5
111
106
  7
112
107
  7
@@ -200,72 +195,97 @@ i
200
195
  7
201
196
  26
202
197
  65
203
- 67
198
+ 5
204
199
  49
205
200
  27
201
+ 4
202
+ 15
203
+ 99
204
+ 7
205
+ 28
206
+ 7
207
+ 29
208
+ 65
209
+ 67
210
+ 49
211
+ 30
206
212
  0
207
213
  49
208
- 28
214
+ 31
209
215
  4
210
216
  15
211
217
  99
212
218
  7
213
- 29
219
+ 32
214
220
  7
215
- 30
221
+ 33
216
222
  65
217
223
  67
218
224
  49
219
- 27
225
+ 30
220
226
  0
221
227
  49
222
- 28
228
+ 31
223
229
  4
224
230
  15
225
231
  99
226
232
  7
227
- 31
233
+ 34
228
234
  7
229
- 32
235
+ 35
230
236
  65
231
237
  67
232
238
  49
233
- 27
239
+ 30
234
240
  0
235
241
  49
236
- 28
242
+ 31
237
243
  4
238
244
  15
239
245
  99
240
246
  7
241
- 33
247
+ 36
242
248
  7
243
- 34
249
+ 37
244
250
  65
245
251
  67
246
252
  49
247
- 27
253
+ 30
248
254
  0
249
255
  49
250
- 28
256
+ 31
251
257
  4
252
258
  15
253
259
  5
254
260
  48
255
- 35
261
+ 38
262
+ 15
263
+ 99
264
+ 7
265
+ 39
266
+ 7
267
+ 40
268
+ 65
269
+ 67
270
+ 49
271
+ 30
272
+ 0
273
+ 49
274
+ 31
275
+ 4
256
276
  15
257
277
  99
258
278
  7
259
279
  21
260
280
  7
261
- 36
281
+ 41
262
282
  65
263
283
  67
264
284
  49
265
- 27
285
+ 30
266
286
  0
267
287
  49
268
- 28
288
+ 31
269
289
  4
270
290
  11
271
291
  I
@@ -278,7 +298,7 @@ I
278
298
  0
279
299
  n
280
300
  p
281
- 37
301
+ 42
282
302
  x
283
303
  10
284
304
  Doorkeeper
@@ -292,12 +312,12 @@ RandomString
292
312
  x
293
313
  7
294
314
  include
295
- s
315
+ x
296
316
  19
297
317
  oauth_access_tokens
298
318
  x
299
- 11
300
- table_name=
319
+ 14
320
+ set_table_name
301
321
  x
302
322
  11
303
323
  application
@@ -353,15 +373,123 @@ x
353
373
  17
354
374
  before_validation
355
375
  x
356
- 7
357
- revoke!
376
+ 14
377
+ authorized_for
358
378
  M
359
379
  1
360
380
  n
361
381
  n
362
382
  x
383
+ 14
384
+ authorized_for
385
+ i
386
+ 35
387
+ 5
388
+ 48
389
+ 0
390
+ 44
391
+ 43
392
+ 1
393
+ 80
394
+ 49
395
+ 2
396
+ 1
397
+ 13
363
398
  7
364
- revoke!
399
+ 3
400
+ 20
401
+ 0
402
+ 49
403
+ 4
404
+ 2
405
+ 15
406
+ 13
407
+ 7
408
+ 5
409
+ 20
410
+ 1
411
+ 49
412
+ 4
413
+ 2
414
+ 15
415
+ 49
416
+ 6
417
+ 1
418
+ 49
419
+ 7
420
+ 0
421
+ 11
422
+ I
423
+ 7
424
+ I
425
+ 2
426
+ I
427
+ 2
428
+ I
429
+ 2
430
+ n
431
+ p
432
+ 8
433
+ x
434
+ 10
435
+ accessible
436
+ x
437
+ 4
438
+ Hash
439
+ x
440
+ 16
441
+ new_from_literal
442
+ x
443
+ 14
444
+ application_id
445
+ x
446
+ 3
447
+ []=
448
+ x
449
+ 17
450
+ resource_owner_id
451
+ x
452
+ 5
453
+ where
454
+ x
455
+ 5
456
+ first
457
+ p
458
+ 5
459
+ I
460
+ -1
461
+ I
462
+ e
463
+ I
464
+ 0
465
+ I
466
+ f
467
+ I
468
+ 23
469
+ x
470
+ 66
471
+ /Users/felipeelias/Applicake/doorkeeper/app/models/access_token.rb
472
+ p
473
+ 2
474
+ x
475
+ 14
476
+ application_id
477
+ x
478
+ 17
479
+ resource_owner_id
480
+ x
481
+ 13
482
+ attach_method
483
+ x
484
+ 6
485
+ revoke
486
+ M
487
+ 1
488
+ n
489
+ n
490
+ x
491
+ 6
492
+ revoke
365
493
  i
366
494
  14
367
495
  5
@@ -407,11 +535,11 @@ p
407
535
  I
408
536
  -1
409
537
  I
410
- e
538
+ 12
411
539
  I
412
540
  0
413
541
  I
414
- f
542
+ 13
415
543
  I
416
544
  e
417
545
  x
@@ -467,11 +595,11 @@ p
467
595
  I
468
596
  -1
469
597
  I
470
- 12
598
+ 16
471
599
  I
472
600
  0
473
601
  I
474
- 13
602
+ 17
475
603
  I
476
604
  8
477
605
  x
@@ -490,17 +618,16 @@ x
490
618
  8
491
619
  expired?
492
620
  i
493
- 24
621
+ 22
494
622
  5
495
- 49
496
- 0
623
+ 48
497
624
  0
498
625
  49
499
626
  1
500
627
  0
501
628
  13
502
629
  9
503
- 23
630
+ 21
504
631
  15
505
632
  45
506
633
  2
@@ -509,11 +636,10 @@ i
509
636
  4
510
637
  0
511
638
  5
512
- 49
513
- 0
514
- 0
515
- 85
639
+ 48
516
640
  5
641
+ 85
642
+ 6
517
643
  11
518
644
  I
519
645
  2
@@ -525,21 +651,24 @@ I
525
651
  0
526
652
  n
527
653
  p
528
- 6
654
+ 7
529
655
  x
530
656
  10
531
- expires_at
657
+ expires_in
532
658
  x
533
659
  8
534
660
  present?
535
661
  x
536
- 8
537
- DateTime
662
+ 4
663
+ Time
538
664
  n
539
665
  x
540
666
  3
541
667
  now
542
668
  x
669
+ 12
670
+ expired_time
671
+ x
543
672
  1
544
673
  >
545
674
  p
@@ -547,13 +676,13 @@ p
547
676
  I
548
677
  -1
549
678
  I
550
- 16
679
+ 1a
551
680
  I
552
681
  0
553
682
  I
554
- 17
683
+ 1b
555
684
  I
556
- 18
685
+ 16
557
686
  x
558
687
  66
559
688
  /Users/felipeelias/Applicake/doorkeeper/app/models/access_token.rb
@@ -620,11 +749,11 @@ p
620
749
  I
621
750
  -1
622
751
  I
623
- 1a
752
+ 1e
624
753
  I
625
754
  0
626
755
  I
627
- 1b
756
+ 1f
628
757
  I
629
758
  1b
630
759
  x
@@ -635,6 +764,71 @@ p
635
764
  x
636
765
  7
637
766
  private
767
+ x
768
+ 12
769
+ expired_time
770
+ M
771
+ 1
772
+ n
773
+ n
774
+ x
775
+ 12
776
+ expired_time
777
+ i
778
+ 13
779
+ 5
780
+ 49
781
+ 0
782
+ 0
783
+ 5
784
+ 48
785
+ 1
786
+ 49
787
+ 2
788
+ 0
789
+ 81
790
+ 3
791
+ 11
792
+ I
793
+ 2
794
+ I
795
+ 0
796
+ I
797
+ 0
798
+ I
799
+ 0
800
+ n
801
+ p
802
+ 4
803
+ x
804
+ 10
805
+ created_at
806
+ x
807
+ 10
808
+ expires_in
809
+ x
810
+ 7
811
+ seconds
812
+ x
813
+ 1
814
+ +
815
+ p
816
+ 5
817
+ I
818
+ -1
819
+ I
820
+ 24
821
+ I
822
+ 0
823
+ I
824
+ 25
825
+ I
826
+ d
827
+ x
828
+ 66
829
+ /Users/felipeelias/Applicake/doorkeeper/app/models/access_token.rb
830
+ p
831
+ 0
638
832
  M
639
833
  1
640
834
  n
@@ -686,15 +880,15 @@ p
686
880
  I
687
881
  -1
688
882
  I
689
- 20
883
+ 28
690
884
  I
691
885
  0
692
886
  I
693
- 23
887
+ 2b
694
888
  I
695
889
  1
696
890
  I
697
- 21
891
+ 29
698
892
  I
699
893
  11
700
894
  x
@@ -703,7 +897,7 @@ x
703
897
  p
704
898
  0
705
899
  p
706
- 27
900
+ 29
707
901
  I
708
902
  2
709
903
  I
@@ -711,53 +905,57 @@ I
711
905
  I
712
906
  f
713
907
  I
714
- 23
715
- I
716
- 10
717
- I
718
908
  4
719
909
  I
720
- 1c
910
+ 17
721
911
  I
722
912
  6
723
913
  I
724
- 24
914
+ 1f
725
915
  I
726
916
  8
727
917
  I
728
- 40
918
+ 3b
729
919
  I
730
920
  a
731
921
  I
732
- 5b
922
+ 56
733
923
  I
734
924
  c
735
925
  I
736
- 73
926
+ 6e
737
927
  I
738
928
  e
739
929
  I
740
- 81
930
+ 79
741
931
  I
742
932
  12
743
933
  I
744
- 8f
934
+ 87
745
935
  I
746
936
  16
747
937
  I
748
- 9d
938
+ 95
749
939
  I
750
940
  1a
751
941
  I
752
- ab
942
+ a3
753
943
  I
754
944
  1e
755
945
  I
756
- af
946
+ b1
757
947
  I
758
- 20
948
+ 22
949
+ I
950
+ b5
951
+ I
952
+ 24
953
+ I
954
+ c3
955
+ I
956
+ 28
759
957
  I
760
- bd
958
+ d1
761
959
  x
762
960
  66
763
961
  /Users/felipeelias/Applicake/doorkeeper/app/models/access_token.rb