File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace webrium ;
3+
4+ class Header
5+ {
6+
7+ public static function all (){
8+ return getallheaders ();
9+ }
10+
11+
12+
13+ /**
14+ * Get header Authorization
15+ */
16+ public static function getAuthorizationHeader ()
17+ {
18+ $ headers = null ;
19+ if (isset ($ _SERVER ['Authorization ' ])) {
20+ $ headers = trim ($ _SERVER ["Authorization " ]);
21+ } else if (isset ($ _SERVER ['HTTP_AUTHORIZATION ' ])) { //Nginx or fast CGI
22+ $ headers = trim ($ _SERVER ["HTTP_AUTHORIZATION " ]);
23+ } elseif (function_exists ('apache_request_headers ' )) {
24+ $ requestHeaders = apache_request_headers ();
25+ // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization)
26+ $ requestHeaders = array_combine (array_map ('ucwords ' , array_keys ($ requestHeaders )), array_values ($ requestHeaders ));
27+
28+ if (isset ($ requestHeaders ['Authorization ' ])) {
29+ $ headers = trim ($ requestHeaders ['Authorization ' ]);
30+ }
31+ }
32+ return $ headers ;
33+ }
34+
35+ /**
36+ * get access token from header
37+ */
38+ public static function getBearerToken ()
39+ {
40+ $ headers = self ::getAuthorizationHeader ();
41+
42+ if (!empty ($ headers )) {
43+ return substr ($ headers , 7 );
44+ }
45+
46+ return false ;
47+ }
48+
49+ }
You can’t perform that action at this time.
0 commit comments