@@ -62,15 +62,15 @@ public function getAuthorizationMethod()
6262 public function authenticate (Request $ request , Route $ route )
6363 {
6464 if (!$ request ->bearerToken () || empty ($ request ->bearerToken ())) {
65- APILogService::log ($ request );
66- throw new UnauthorizedHttpException ('The authentication header was missing or malformed ' );
65+ APILogService::log ($ request, ' The authentication header was missing or malformed. ' );
66+ throw new UnauthorizedHttpException ('The authentication header was missing or malformed. ' );
6767 }
6868
6969 list ($ public , $ hashed ) = explode ('. ' , $ request ->bearerToken ());
7070
7171 $ key = APIKey::where ('public ' , $ public )->first ();
7272 if (!$ key ) {
73- APILogService::log ($ request );
73+ APILogService::log ($ request, ' Invalid API Key. ' );
7474 throw new AccessDeniedHttpException ('Invalid API Key. ' );
7575 }
7676
@@ -85,7 +85,7 @@ public function authenticate(Request $request, Route $route)
8585 }
8686 }
8787 if (!$ inRange ) {
88- APILogService::log ($ request );
88+ APILogService::log ($ request, ' This IP address < ' . $ request -> ip () . ' > does not have permission to use this API key. ' );
8989 throw new AccessDeniedHttpException ('This IP address < ' . $ request ->ip () . '> does not have permission to use this API key. ' );
9090 }
9191 }
@@ -98,26 +98,26 @@ public function authenticate(Request $request, Route $route)
9898 }
9999
100100 if (!$ this ->permissionAllowed ) {
101- APILogService::log ($ request );
101+ APILogService::log ($ request, ' You do not have permission to access this resource. ' );
102102 throw new AccessDeniedHttpException ('You do not have permission to access this resource. ' );
103103 }
104104 }
105105
106106 try {
107107 $ decrypted = Crypt::decrypt ($ key ->secret );
108108 } catch (\Illuminate \Contracts \Encryption \DecryptException $ ex ) {
109- APILogService::log ($ request );
109+ APILogService::log ($ request, ' There was an error while attempting to check your secret key. ' );
110110 throw new HttpException ('There was an error while attempting to check your secret key. ' );
111111 }
112112
113113 $ this ->url = urldecode ($ request ->fullUrl ());
114114 if ($ this ->_generateHMAC ($ request ->getContent (), $ decrypted ) !== base64_decode ($ hashed )) {
115- APILogService::log ($ request );
115+ APILogService::log ($ request, ' The hashed body was not valid. Potential modification of contents in route. ' );
116116 throw new BadRequestHttpException ('The hashed body was not valid. Potential modification of contents in route. ' );
117117 }
118118
119119 // Log the Route Access
120- APILogService::log ($ request , true );
120+ APILogService::log ($ request , null , true );
121121 return true ;
122122
123123 }
0 commit comments