doorkeeper 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- data/README.md +42 -14
- data/Rakefile +1 -1
- data/app/assets/stylesheets/doorkeeper/application.css +4 -0
- data/app/controllers/doorkeeper/application_controller.rb +2 -2
- data/app/controllers/doorkeeper/application_controller.rbc +32 -20
- data/app/controllers/doorkeeper/authorizations_controller.rbc +86 -22
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +13 -0
- data/app/controllers/doorkeeper/authorized_applications_controller.rbc +393 -0
- data/app/controllers/doorkeeper/tokens_controller.rb +4 -0
- data/app/models/access_grant.rb +8 -0
- data/app/models/access_grant.rbc +204 -39
- data/app/models/access_token.rb +31 -3
- data/app/models/access_token.rbc +270 -72
- data/app/models/application.rb +8 -1
- data/app/models/application.rbc +307 -61
- data/app/views/doorkeeper/authorizations/new.html.erb +17 -0
- data/app/views/doorkeeper/authorized_applications/index.html.erb +26 -0
- data/config/routes.rb +1 -0
- data/config/routes.rbc +48 -4
- data/lib/doorkeeper/config.rb +82 -22
- data/lib/doorkeeper/config.rbc +739 -295
- data/lib/doorkeeper/config/scope.rb +11 -0
- data/lib/doorkeeper/config/scopes.rb +57 -0
- data/lib/doorkeeper/config/scopes_builder.rb +18 -0
- data/lib/doorkeeper/doorkeeper_for.rb +96 -16
- data/lib/doorkeeper/oauth/access_token_request.rb +57 -18
- data/lib/doorkeeper/oauth/access_token_request.rbc +256 -67
- data/lib/doorkeeper/oauth/authorization_request.rb +31 -4
- data/lib/doorkeeper/oauth/authorization_request.rbc +230 -65
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/doorkeeper/version.rbc +1 -1
- data/lib/generators/doorkeeper/templates/README +3 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +13 -0
- data/lib/generators/doorkeeper/templates/migration.rb +4 -1
- metadata +35 -18
@@ -16,6 +16,7 @@ module Doorkeeper::OAuth
|
|
16
16
|
validate :client, :error => :invalid_client
|
17
17
|
validate :redirect_uri, :error => :invalid_redirect_uri
|
18
18
|
validate :response_type, :error => :unsupported_response_type
|
19
|
+
validate :scope, :error => :invalid_scope
|
19
20
|
|
20
21
|
attr_accessor *ATTRIBUTES
|
21
22
|
attr_accessor :resource_owner, :error
|
@@ -24,6 +25,7 @@ module Doorkeeper::OAuth
|
|
24
25
|
ATTRIBUTES.each { |attr| instance_variable_set("@#{attr}", attributes[attr]) }
|
25
26
|
@resource_owner = resource_owner
|
26
27
|
@grant = nil
|
28
|
+
@scope ||= Doorkeeper.configuration.default_scope_string
|
27
29
|
validate
|
28
30
|
end
|
29
31
|
|
@@ -32,8 +34,7 @@ module Doorkeeper::OAuth
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def access_token_exists?
|
35
|
-
|
36
|
-
!token.first.nil?
|
37
|
+
access_token.present? && access_token_scope_matches?
|
37
38
|
end
|
38
39
|
|
39
40
|
def deny
|
@@ -49,13 +50,21 @@ module Doorkeeper::OAuth
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def invalid_redirect_uri
|
52
|
-
build_uri
|
53
|
+
build_uri do |uri|
|
54
|
+
query = "error=#{error}"
|
55
|
+
query << "&state=#{state}" if has_state?
|
56
|
+
uri.query = query
|
57
|
+
end
|
53
58
|
end
|
54
59
|
|
55
60
|
def client
|
56
61
|
@client ||= Application.find_by_uid(client_id)
|
57
62
|
end
|
58
63
|
|
64
|
+
def scopes
|
65
|
+
Doorkeeper.configuration.scopes.with_names(*scope.split(" ")) if has_scope?
|
66
|
+
end
|
67
|
+
|
59
68
|
private
|
60
69
|
|
61
70
|
def create_authorization
|
@@ -63,7 +72,8 @@ module Doorkeeper::OAuth
|
|
63
72
|
:application_id => client.id,
|
64
73
|
:resource_owner_id => resource_owner.id,
|
65
74
|
:expires_in => DEFAULT_EXPIRATION_TIME,
|
66
|
-
:redirect_uri => redirect_uri
|
75
|
+
:redirect_uri => redirect_uri,
|
76
|
+
:scopes => scope
|
67
77
|
)
|
68
78
|
end
|
69
79
|
|
@@ -71,6 +81,10 @@ module Doorkeeper::OAuth
|
|
71
81
|
state.present?
|
72
82
|
end
|
73
83
|
|
84
|
+
def has_scope?
|
85
|
+
Doorkeeper.configuration.scopes.all.present?
|
86
|
+
end
|
87
|
+
|
74
88
|
def token
|
75
89
|
@grant.token
|
76
90
|
end
|
@@ -96,5 +110,18 @@ module Doorkeeper::OAuth
|
|
96
110
|
def validate_response_type
|
97
111
|
response_type == "code"
|
98
112
|
end
|
113
|
+
|
114
|
+
def validate_scope
|
115
|
+
return true unless has_scope?
|
116
|
+
scope.present? && scope !~ /[\n|\r|\t]/ && scope.split(" ").all? { |s| Doorkeeper.configuration.scopes.exists?(s) }
|
117
|
+
end
|
118
|
+
|
119
|
+
def access_token
|
120
|
+
AccessToken.accessible.where(:application_id => client.id, :resource_owner_id => resource_owner.id).first
|
121
|
+
end
|
122
|
+
|
123
|
+
def access_token_scope_matches?
|
124
|
+
(access_token.scopes - scope.split(" ").map(&:to_sym)).empty?
|
125
|
+
end
|
99
126
|
end
|
100
127
|
end
|
@@ -130,7 +130,7 @@ x
|
|
130
130
|
20
|
131
131
|
AuthorizationRequest
|
132
132
|
i
|
133
|
-
|
133
|
+
372
|
134
134
|
5
|
135
135
|
66
|
136
136
|
5
|
@@ -347,9 +347,9 @@ i
|
|
347
347
|
15
|
348
348
|
99
|
349
349
|
7
|
350
|
-
22
|
351
|
-
7
|
352
350
|
37
|
351
|
+
7
|
352
|
+
38
|
353
353
|
65
|
354
354
|
67
|
355
355
|
49
|
@@ -361,9 +361,9 @@ i
|
|
361
361
|
15
|
362
362
|
99
|
363
363
|
7
|
364
|
-
|
364
|
+
22
|
365
365
|
7
|
366
|
-
|
366
|
+
39
|
367
367
|
65
|
368
368
|
67
|
369
369
|
49
|
@@ -373,15 +373,11 @@ i
|
|
373
373
|
30
|
374
374
|
4
|
375
375
|
15
|
376
|
-
5
|
377
|
-
48
|
378
|
-
39
|
379
|
-
15
|
380
376
|
99
|
381
377
|
7
|
382
|
-
|
378
|
+
20
|
383
379
|
7
|
384
|
-
|
380
|
+
40
|
385
381
|
65
|
386
382
|
67
|
387
383
|
49
|
@@ -391,6 +387,10 @@ i
|
|
391
387
|
30
|
392
388
|
4
|
393
389
|
15
|
390
|
+
5
|
391
|
+
48
|
392
|
+
41
|
393
|
+
15
|
394
394
|
99
|
395
395
|
7
|
396
396
|
42
|
@@ -488,6 +488,20 @@ i
|
|
488
488
|
49
|
489
489
|
30
|
490
490
|
4
|
491
|
+
15
|
492
|
+
99
|
493
|
+
7
|
494
|
+
56
|
495
|
+
7
|
496
|
+
57
|
497
|
+
65
|
498
|
+
67
|
499
|
+
49
|
500
|
+
29
|
501
|
+
0
|
502
|
+
49
|
503
|
+
30
|
504
|
+
4
|
491
505
|
11
|
492
506
|
I
|
493
507
|
7
|
@@ -499,7 +513,7 @@ I
|
|
499
513
|
0
|
500
514
|
n
|
501
515
|
p
|
502
|
-
|
516
|
+
58
|
503
517
|
x
|
504
518
|
10
|
505
519
|
Doorkeeper
|
@@ -823,6 +837,153 @@ x
|
|
823
837
|
p
|
824
838
|
0
|
825
839
|
x
|
840
|
+
20
|
841
|
+
access_token_exists?
|
842
|
+
M
|
843
|
+
1
|
844
|
+
n
|
845
|
+
n
|
846
|
+
x
|
847
|
+
20
|
848
|
+
access_token_exists?
|
849
|
+
i
|
850
|
+
60
|
851
|
+
45
|
852
|
+
0
|
853
|
+
1
|
854
|
+
49
|
855
|
+
2
|
856
|
+
0
|
857
|
+
44
|
858
|
+
43
|
859
|
+
3
|
860
|
+
80
|
861
|
+
49
|
862
|
+
4
|
863
|
+
1
|
864
|
+
13
|
865
|
+
7
|
866
|
+
5
|
867
|
+
5
|
868
|
+
48
|
869
|
+
6
|
870
|
+
49
|
871
|
+
7
|
872
|
+
0
|
873
|
+
49
|
874
|
+
8
|
875
|
+
2
|
876
|
+
15
|
877
|
+
13
|
878
|
+
7
|
879
|
+
9
|
880
|
+
5
|
881
|
+
48
|
882
|
+
10
|
883
|
+
49
|
884
|
+
7
|
885
|
+
0
|
886
|
+
49
|
887
|
+
8
|
888
|
+
2
|
889
|
+
15
|
890
|
+
49
|
891
|
+
11
|
892
|
+
1
|
893
|
+
19
|
894
|
+
0
|
895
|
+
15
|
896
|
+
20
|
897
|
+
0
|
898
|
+
49
|
899
|
+
12
|
900
|
+
0
|
901
|
+
49
|
902
|
+
13
|
903
|
+
0
|
904
|
+
10
|
905
|
+
58
|
906
|
+
2
|
907
|
+
8
|
908
|
+
59
|
909
|
+
3
|
910
|
+
11
|
911
|
+
I
|
912
|
+
6
|
913
|
+
I
|
914
|
+
1
|
915
|
+
I
|
916
|
+
0
|
917
|
+
I
|
918
|
+
0
|
919
|
+
n
|
920
|
+
p
|
921
|
+
14
|
922
|
+
x
|
923
|
+
11
|
924
|
+
AccessToken
|
925
|
+
n
|
926
|
+
x
|
927
|
+
10
|
928
|
+
accessible
|
929
|
+
x
|
930
|
+
4
|
931
|
+
Hash
|
932
|
+
x
|
933
|
+
16
|
934
|
+
new_from_literal
|
935
|
+
x
|
936
|
+
14
|
937
|
+
application_id
|
938
|
+
x
|
939
|
+
6
|
940
|
+
client
|
941
|
+
x
|
942
|
+
2
|
943
|
+
id
|
944
|
+
x
|
945
|
+
3
|
946
|
+
[]=
|
947
|
+
x
|
948
|
+
17
|
949
|
+
resource_owner_id
|
950
|
+
x
|
951
|
+
14
|
952
|
+
resource_owner
|
953
|
+
x
|
954
|
+
5
|
955
|
+
where
|
956
|
+
x
|
957
|
+
5
|
958
|
+
first
|
959
|
+
x
|
960
|
+
4
|
961
|
+
nil?
|
962
|
+
p
|
963
|
+
7
|
964
|
+
I
|
965
|
+
-1
|
966
|
+
I
|
967
|
+
22
|
968
|
+
I
|
969
|
+
0
|
970
|
+
I
|
971
|
+
23
|
972
|
+
I
|
973
|
+
2d
|
974
|
+
I
|
975
|
+
24
|
976
|
+
I
|
977
|
+
3c
|
978
|
+
x
|
979
|
+
85
|
980
|
+
/Users/felipeelias/Applicake/doorkeeper/lib/doorkeeper/oauth/authorization_request.rb
|
981
|
+
p
|
982
|
+
1
|
983
|
+
x
|
984
|
+
5
|
985
|
+
token
|
986
|
+
x
|
826
987
|
4
|
827
988
|
deny
|
828
989
|
M
|
@@ -868,15 +1029,15 @@ p
|
|
868
1029
|
I
|
869
1030
|
-1
|
870
1031
|
I
|
871
|
-
|
1032
|
+
27
|
872
1033
|
I
|
873
1034
|
0
|
874
1035
|
I
|
875
|
-
|
1036
|
+
64
|
876
1037
|
I
|
877
1038
|
1
|
878
1039
|
I
|
879
|
-
|
1040
|
+
28
|
880
1041
|
I
|
881
1042
|
c
|
882
1043
|
x
|
@@ -1024,15 +1185,15 @@ p
|
|
1024
1185
|
I
|
1025
1186
|
0
|
1026
1187
|
I
|
1027
|
-
|
1188
|
+
2c
|
1028
1189
|
I
|
1029
1190
|
4
|
1030
1191
|
I
|
1031
|
-
|
1192
|
+
2d
|
1032
1193
|
I
|
1033
1194
|
11
|
1034
1195
|
I
|
1035
|
-
|
1196
|
+
2e
|
1036
1197
|
I
|
1037
1198
|
2a
|
1038
1199
|
I
|
@@ -1040,7 +1201,7 @@ I
|
|
1040
1201
|
I
|
1041
1202
|
2b
|
1042
1203
|
I
|
1043
|
-
|
1204
|
+
2f
|
1044
1205
|
I
|
1045
1206
|
37
|
1046
1207
|
x
|
@@ -1062,11 +1223,11 @@ p
|
|
1062
1223
|
I
|
1063
1224
|
-1
|
1064
1225
|
I
|
1065
|
-
|
1226
|
+
2b
|
1066
1227
|
I
|
1067
1228
|
0
|
1068
1229
|
I
|
1069
|
-
|
1230
|
+
2c
|
1070
1231
|
I
|
1071
1232
|
8
|
1072
1233
|
x
|
@@ -1168,7 +1329,7 @@ p
|
|
1168
1329
|
I
|
1169
1330
|
0
|
1170
1331
|
I
|
1171
|
-
|
1332
|
+
34
|
1172
1333
|
I
|
1173
1334
|
18
|
1174
1335
|
x
|
@@ -1187,11 +1348,11 @@ p
|
|
1187
1348
|
I
|
1188
1349
|
-1
|
1189
1350
|
I
|
1190
|
-
|
1351
|
+
33
|
1191
1352
|
I
|
1192
1353
|
0
|
1193
1354
|
I
|
1194
|
-
|
1355
|
+
34
|
1195
1356
|
I
|
1196
1357
|
8
|
1197
1358
|
x
|
@@ -1255,11 +1416,11 @@ p
|
|
1255
1416
|
I
|
1256
1417
|
-1
|
1257
1418
|
I
|
1258
|
-
|
1419
|
+
37
|
1259
1420
|
I
|
1260
1421
|
0
|
1261
1422
|
I
|
1262
|
-
|
1423
|
+
38
|
1263
1424
|
I
|
1264
1425
|
12
|
1265
1426
|
x
|
@@ -1405,35 +1566,35 @@ p
|
|
1405
1566
|
I
|
1406
1567
|
-1
|
1407
1568
|
I
|
1408
|
-
|
1569
|
+
3d
|
1409
1570
|
I
|
1410
1571
|
0
|
1411
1572
|
I
|
1412
|
-
|
1573
|
+
3e
|
1413
1574
|
I
|
1414
1575
|
3
|
1415
1576
|
I
|
1416
|
-
|
1577
|
+
42
|
1417
1578
|
I
|
1418
1579
|
c
|
1419
1580
|
I
|
1420
|
-
|
1581
|
+
3f
|
1421
1582
|
I
|
1422
1583
|
19
|
1423
1584
|
I
|
1424
|
-
|
1585
|
+
40
|
1425
1586
|
I
|
1426
1587
|
26
|
1427
1588
|
I
|
1428
|
-
|
1589
|
+
41
|
1429
1590
|
I
|
1430
1591
|
30
|
1431
1592
|
I
|
1432
|
-
|
1593
|
+
42
|
1433
1594
|
I
|
1434
1595
|
39
|
1435
1596
|
I
|
1436
|
-
|
1597
|
+
3e
|
1437
1598
|
I
|
1438
1599
|
3f
|
1439
1600
|
x
|
@@ -1482,11 +1643,11 @@ p
|
|
1482
1643
|
I
|
1483
1644
|
-1
|
1484
1645
|
I
|
1485
|
-
|
1646
|
+
46
|
1486
1647
|
I
|
1487
1648
|
0
|
1488
1649
|
I
|
1489
|
-
|
1650
|
+
47
|
1490
1651
|
I
|
1491
1652
|
7
|
1492
1653
|
x
|
@@ -1534,11 +1695,11 @@ p
|
|
1534
1695
|
I
|
1535
1696
|
-1
|
1536
1697
|
I
|
1537
|
-
|
1698
|
+
4a
|
1538
1699
|
I
|
1539
1700
|
0
|
1540
1701
|
I
|
1541
|
-
|
1702
|
+
4b
|
1542
1703
|
I
|
1543
1704
|
6
|
1544
1705
|
x
|
@@ -1616,19 +1777,19 @@ p
|
|
1616
1777
|
I
|
1617
1778
|
-1
|
1618
1779
|
I
|
1619
|
-
|
1780
|
+
4e
|
1620
1781
|
I
|
1621
1782
|
0
|
1622
1783
|
I
|
1623
|
-
|
1784
|
+
4f
|
1624
1785
|
I
|
1625
1786
|
f
|
1626
1787
|
I
|
1627
|
-
|
1788
|
+
50
|
1628
1789
|
I
|
1629
1790
|
14
|
1630
1791
|
I
|
1631
|
-
|
1792
|
+
51
|
1632
1793
|
I
|
1633
1794
|
1a
|
1634
1795
|
x
|
@@ -1739,7 +1900,7 @@ p
|
|
1739
1900
|
I
|
1740
1901
|
0
|
1741
1902
|
I
|
1742
|
-
|
1903
|
+
55
|
1743
1904
|
I
|
1744
1905
|
f
|
1745
1906
|
x
|
@@ -1758,11 +1919,11 @@ p
|
|
1758
1919
|
I
|
1759
1920
|
-1
|
1760
1921
|
I
|
1761
|
-
|
1922
|
+
54
|
1762
1923
|
I
|
1763
1924
|
0
|
1764
1925
|
I
|
1765
|
-
|
1926
|
+
55
|
1766
1927
|
I
|
1767
1928
|
11
|
1768
1929
|
x
|
@@ -1817,11 +1978,11 @@ p
|
|
1817
1978
|
I
|
1818
1979
|
-1
|
1819
1980
|
I
|
1820
|
-
|
1981
|
+
58
|
1821
1982
|
I
|
1822
1983
|
0
|
1823
1984
|
I
|
1824
|
-
|
1985
|
+
59
|
1825
1986
|
I
|
1826
1987
|
10
|
1827
1988
|
x
|
@@ -1878,11 +2039,11 @@ p
|
|
1878
2039
|
I
|
1879
2040
|
-1
|
1880
2041
|
I
|
1881
|
-
|
2042
|
+
5c
|
1882
2043
|
I
|
1883
2044
|
0
|
1884
2045
|
I
|
1885
|
-
|
2046
|
+
5d
|
1886
2047
|
I
|
1887
2048
|
c
|
1888
2049
|
x
|
@@ -1936,11 +2097,11 @@ p
|
|
1936
2097
|
I
|
1937
2098
|
-1
|
1938
2099
|
I
|
1939
|
-
|
2100
|
+
60
|
1940
2101
|
I
|
1941
2102
|
0
|
1942
2103
|
I
|
1943
|
-
|
2104
|
+
61
|
1944
2105
|
I
|
1945
2106
|
9
|
1946
2107
|
x
|
@@ -1949,7 +2110,7 @@ x
|
|
1949
2110
|
p
|
1950
2111
|
0
|
1951
2112
|
p
|
1952
|
-
|
2113
|
+
61
|
1953
2114
|
I
|
1954
2115
|
2
|
1955
2116
|
I
|
@@ -2021,53 +2182,57 @@ I
|
|
2021
2182
|
I
|
2022
2183
|
c8
|
2023
2184
|
I
|
2024
|
-
|
2185
|
+
27
|
2025
2186
|
I
|
2026
2187
|
d6
|
2027
2188
|
I
|
2028
|
-
|
2189
|
+
2b
|
2029
2190
|
I
|
2030
2191
|
e4
|
2031
2192
|
I
|
2032
|
-
|
2193
|
+
33
|
2033
2194
|
I
|
2034
2195
|
f2
|
2035
2196
|
I
|
2036
|
-
|
2197
|
+
37
|
2037
2198
|
I
|
2038
|
-
|
2199
|
+
100
|
2039
2200
|
I
|
2040
|
-
|
2201
|
+
3b
|
2041
2202
|
I
|
2042
2203
|
104
|
2043
2204
|
I
|
2044
|
-
|
2205
|
+
3d
|
2045
2206
|
I
|
2046
2207
|
112
|
2047
2208
|
I
|
2048
|
-
|
2209
|
+
46
|
2049
2210
|
I
|
2050
2211
|
120
|
2051
2212
|
I
|
2052
|
-
|
2213
|
+
4a
|
2053
2214
|
I
|
2054
2215
|
12e
|
2055
2216
|
I
|
2056
|
-
|
2217
|
+
4e
|
2057
2218
|
I
|
2058
2219
|
13c
|
2059
2220
|
I
|
2060
|
-
|
2221
|
+
54
|
2061
2222
|
I
|
2062
2223
|
14a
|
2063
2224
|
I
|
2064
|
-
|
2225
|
+
58
|
2065
2226
|
I
|
2066
2227
|
158
|
2067
2228
|
I
|
2068
|
-
|
2229
|
+
5c
|
2069
2230
|
I
|
2070
2231
|
166
|
2232
|
+
I
|
2233
|
+
60
|
2234
|
+
I
|
2235
|
+
174
|
2071
2236
|
x
|
2072
2237
|
85
|
2073
2238
|
/Users/felipeelias/Applicake/doorkeeper/lib/doorkeeper/oauth/authorization_request.rb
|