66
77class ServiceProviderController extends Controller
88{
9+ private function getAuthenticationSchemes (): array
10+ {
11+ $ allSchemes = [
12+ 'oauth ' => [
13+ 'name ' => 'OAuth ' ,
14+ 'description ' => 'Authentication scheme using the OAuth Standard ' ,
15+ 'specUri ' => 'http://tools.ietf.org/html/rfc5849 ' ,
16+ 'documentationUri ' => 'http://example.com/help/oauth.html ' ,
17+ 'type ' => 'oauth ' ,
18+ ],
19+ 'oauth2 ' => [
20+ 'name ' => 'OAuth 2.0 ' ,
21+ 'description ' => 'Authentication scheme using the OAuth 2.0 Standard ' ,
22+ 'specUri ' => 'http://tools.ietf.org/html/rfc6749 ' ,
23+ 'documentationUri ' => 'http://example.com/help/oauth2.html ' ,
24+ 'type ' => 'oauth2 ' ,
25+ ],
26+ 'oauthbearertoken ' => [
27+ 'name ' => 'OAuth Bearer Token ' ,
28+ 'description ' => 'Authentication scheme using the OAuth Bearer Token Standard ' ,
29+ 'specUri ' => 'http://www.rfc-editor.org/info/rfc6750 ' ,
30+ 'documentationUri ' => 'http://example.com/help/oauth.html ' ,
31+ 'type ' => 'oauthbearertoken ' ,
32+ ],
33+ 'httpbasic ' => [
34+ 'name ' => 'HTTP Basic ' ,
35+ 'description ' => 'Authentication scheme using the HTTP Basic Standard ' ,
36+ 'specUri ' => 'http://www.rfc-editor.org/info/rfc2617 ' ,
37+ 'documentationUri ' => 'http://example.com/help/httpBasic.html ' ,
38+ 'type ' => 'httpbasic ' ,
39+ ],
40+ 'httpdigest ' => [
41+ 'name ' => 'HTTP Digest ' ,
42+ 'description ' => 'Authentication scheme using the HTTP Digest Standard ' ,
43+ 'specUri ' => 'http://www.rfc-editor.org/info/rfc2617 ' ,
44+ 'documentationUri ' => 'http://example.com/help/httpDigest.html ' ,
45+ 'type ' => 'httpdigest ' ,
46+ ],
47+ ];
48+
49+ $ schemes = config ('scim.authenticationSchemes ' , ['oauthbearertoken ' ]);
50+ $ authenticationSchemes = [];
51+
52+ foreach ($ schemes as $ index => $ scheme ) {
53+ if (isset ($ allSchemes [$ scheme ])) {
54+ $ authenticationSchemes [] = array_merge (
55+ $ allSchemes [$ scheme ],
56+ ['primary ' => $ index === 0 ]
57+ );
58+ }
59+ }
60+
61+ return $ authenticationSchemes ;
62+ }
63+
964 public function index ()
1065 {
1166 $ cursorPaginationEnabled = (bool ) config ('scim.pagination.cursorPaginationEnabled ' , true );
@@ -22,6 +77,8 @@ public function index()
2277 $ pagination ["cursorTimeout " ] = 3600 ;
2378 }
2479
80+ $ authenticationSchemes = $ this ->getAuthenticationSchemes ();
81+
2582 return [
2683 "schemas " => ["urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig " ],
2784 "patch " => [
@@ -45,25 +102,7 @@ public function index()
45102 "etag " => [
46103 "supported " => true ,
47104 ],
48- "authenticationSchemes " => [ // "oauth", "oauth2", "oauthbearertoken", "httpbasic", and "httpdigest"
49- [
50- "name " => "OAuth Bearer Token " ,
51- "description " =>
52- "Authentication scheme using the OAuth Bearer Token Standard " ,
53- "specUri " => "http://www.rfc-editor.org/info/rfc6750 " ,
54- "documentationUri " => "http://example.com/help/oauth.html " ,
55- "type " => "oauthbearertoken " ,
56- "primary " => true ,
57- ],
58- [
59- "name " => "HTTP Basic " ,
60- "description " =>
61- "Authentication scheme using the HTTP Basic Standard " ,
62- "specUri " => "http://www.rfc-editor.org/info/rfc2617 " ,
63- "documentationUri " => "http://example.com/help/httpBasic.html " ,
64- "type " => "httpbasic " ,
65- ],
66- ],
105+ "authenticationSchemes " => $ authenticationSchemes ,
67106 "pagination " => $ pagination ,
68107 "meta " => [
69108 "location " => route ('scim.serviceproviderconfig ' ),
0 commit comments