尊龙凯时人生就是博

laravel 5.7»á¼û²»ÁË·ÓÉ

Ëæ×Å laravel 5.7 µÄÍƳö£¬ÓÐÐí¶àÓû§·´Ó¦»á¼û·ÓÉ·ºÆðÁËÎÊÌâ¡£Õâ¸öÎÊÌâµÄ·ºÆð¿ÉÄÜ»áÈÃÄãÔÚ¿ª·¢Àú³ÌÖÐÆÌÕÅ´ó×ÚµÄʱ¼äÀ´´¦Àí¡£ÎªÁË×ÊÖú¸÷È˽â¾öÕâ¸öÎÊÌ⣬±¾ÎĽ«ÏêϸÏÈÈÝ laravel 5.7 »á¼û²»ÁË·ÓɵĽâ¾ö¼Æ»®¡£

Ê×ÏÈÎÒÃÇÐèÒªÏàʶ Laravel 5.7 µÄһЩÐÂת±ä£¬ÕâЩת±ä¿ÉÄܻᵼÖÂ֮ǰµÄ´úÂëÎÞ·¨Õý³£ÔËÐС£ÆäÖÐ×îÖ÷ÒªµÄÒ»¸öת±äÊÇĬÈÏÌí¼ÓÁË CSRF ±£»¤ÖÐÐļþ¡£ÕâÆäÖÐÐļþ¿ÉÒÔÈ·±£Óû§Ìá½»µÄ±íµ¥Êý¾ÝÊÇ·ñÀ´×ÔÓÚÄãµÄÓ¦ÓóÌÐò£¬±ÜÃâÓ¦ÓóÌÐòÔâÊÜ CSRF ¹¥»÷¡£

CSRF ±£»¤ÖÐÐļþÔÚ Laravel 5.6 ÖÐÒѾ­±£´æ£¬µ«Ä¬Èϲ¢Ã»ÓÐÆôÓᣵ«ÔÚ Laravel 5.7 ÖУ¬Laravel ÍŶÓĬÈÏÆôÓÃÁËÕâÆäÖÐÐļþ¡£Òò´Ë£¬ÔÚ Laravel 5.7 ÖУ¬Ê¹ÓÃ±íµ¥Ìá½»Êý¾ÝʱÐèÒªÌí¼Ó CSRF ÁîÅÆ¡£

½â¾öÒªÁ죺

ÓÐÁ½ÖÖÒªÁì¿ÉÒÔ½â¾ö Laravel 5.7 »á¼û²»ÁË·ÓɵÄÎÊÌâ¡£µÚÒ»ÖÖÒªÁìÊÇÔÚ web.php ÎļþÖÐÌí¼Ó CSRF ÁîÅÆ¡£µÚ¶þÖÖÒªÁìÊǽûÓà CSRF ±£»¤ÖÐÐļþ¡£

ÒªÁìÒ»£ºÔÚ web.php ÎļþÖÐÌí¼Ó CSRF ÁîÅÆ

Laravel 5.7 ´úÂëµÄ RouteServiceProvider.php ÖÐĬÈÏʹÓÃÁË web ÖÐÐļþ×飬Òò´Ë£¬ÔÚ web.php ÎļþÖÐÌí¼Ó CSRF ÁîÅÆ×î¼òÆÓµÄÒªÁì¾ÍÊÇʹÓà {{ csrf_field() }} ÒªÁì¡£

ÀýÈ磬ÈôÊÇÄãÓÐÒ»¸ö´¦Àí POST ÇëÇóµÄ·ÓÉ£º

Route::post(‘/foo’, function () {

return 'Hello World';

µÇ¼ºó¸´ÖÆ

});

ÄãÐèÒªÔÚ±íµ¥ÖÐÌí¼Ó {{ csrf_field() }} ÒªÁìÀ´ÌìÉú CSRF ÁîÅÆ£º

{{ csrf_field() }}
<!-- ... -->

µÇ¼ºó¸´ÖÆ

Õâ¸öÒªÁì¿ÉÒÔÈ·±£ÄãµÄ Laravel 5.7 Ó¦ÓóÌÐò¿ÉÒÔÕý³£´¦Àí POST ÇëÇó¡£

ÒªÁì¶þ£º½ûÓà CSRF ±£»¤ÖÐÐļþ

½ûÓà CSRF ±£»¤ÖÐÐļþÊÇÁíÒ»¸ö½â¾ö Laravel 5.7 »á¼û²»ÁË·ÓɵÄÒªÁì¡£ËäÈ»ÕâÖÖÒªÁì¿ÉÄÜ»áÉÔ΢½µµÍÄãµÄ Laravel Ó¦ÓóÌÐòµÄÇå¾²ÐÔ£¬µ«ÈôÊÇÄãµÄÓ¦ÓóÌÐò²»»áÊܵ½ CSRF ¹¥»÷µÄÍþв£¬ÄÇôÕâÖÖÒªÁìÊÇ¿ÉÐеÄ¡£

Òª½ûÓà CSRF ±£»¤ÖÐÐļþ£¬ÄãÐèÒªÔÚ VerifyCsrfToken ÀàµÄ $except ÊôÐÔÖÐÌí¼ÓÒªºöÂ﵀ URI¡£

·­¿ª app/Http/Middleware/VerifyCsrfToken.php Îļþ£¬È»ºóÔÚ $except ÊôÐÔÖÐÌí¼ÓÒªºöÂԵķÓÉ£º

protected $except = [

'your-route-to-ignore'

µÇ¼ºó¸´ÖÆ

];

ÀýÈ磬¼ÙÉèÄãÏëºöÂÔ¡°register¡±Â·ÓÉ£º

protected $except = [

'register'

µÇ¼ºó¸´ÖÆ

];

Õâ¸öÒªÁì¿ÉÒÔÈ·±£ÄãµÄ Laravel 5.7 Ó¦ÓóÌÐò¿ÉÒÔÕý³£´¦ÀíËùÓÐÇëÇó¡£

½áÂÛ£º

×ܵÄÀ´Ëµ£¬ÔÚ Laravel 5.7 Öлá¼û²»ÁË·ÓɵÄÎÊÌâÖ÷ÒªÊÇÓÉÓÚĬÈÏÆôÓÃÁË CSRF ±£»¤ÖÐÐļþËùµ¼ÖµÄ¡£Òò´Ë£¬ÈôÊÇÄãÔÚ¿ª·¢µÄÀú³ÌÖÐÓöµ½ÁËÕâ¸öÎÊÌ⣬¿ÉÒÔʵÑéʹÓÃÕâÁ½ÖÖÒªÁìÀ´½â¾ö¡£ÈôÊÇÄãÒª½ûÓà CSRF ±£»¤ÖÐÐļþ£¬Ó¦¸Ã½ö¶ÔÄÇЩ²»Éæ¼°Ãô¸Ð»òÖ÷ÒªÊý¾ÝµÄ·ÓÉʹÓá£Õâ¸öÒªÁì¿ÉÄÜ»áÂÔ΢½µµÍÄãµÄ Laravel Ó¦ÓóÌÐòµÄÇå¾²ÐÔ£¬Òò´Ë½¨ÒéʹÓÃÒªÁìÒ»À´È·±£ÄãµÄÓ¦ÓóÌÐòµÄÇå¾²ÐÔ¡£

ÒÔÉϾÍÊÇlaravel 5.7»á¼û²»ÁË·ÓɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ