{"id":572,"date":"2024-10-04T14:26:33","date_gmt":"2024-10-04T12:26:33","guid":{"rendered":"https:\/\/portfolio.articole-smart.eu\/?p=572"},"modified":"2024-12-16T10:48:30","modified_gmt":"2024-12-16T09:48:30","slug":"authenticator-2fa-app-in-laravel","status":"publish","type":"post","link":"https:\/\/portfolio.articole-smart.eu\/index.php\/2024\/10\/04\/authenticator-2fa-app-in-laravel\/","title":{"rendered":"Authenticator 2FA App in Laravel"},"content":{"rendered":"\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(234, 191, 191, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\n\nnamespace App\\Models;\n\n\/\/ use Illuminate\\Contracts\\Auth\\MustVerifyEmail;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\nuse Illuminate\\Notifications\\Notifiable;\nuse Laravel\\Fortify\\TwoFactorAuthenticatable;\nuse Laravel\\Sanctum\\HasApiTokens;\n\nclass User extends Authenticatable\n{\n    use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;\n\n    \/* The rest of the User Model code .. *\/\n}\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">namespace<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">App\\Models<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ use Illuminate\\Contracts\\Auth\\MustVerifyEmail;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">use<\/span><span style=\"color: #D4D4D4\"> Illuminate\\Database\\Eloquent\\Factories\\<\/span><span style=\"color: #4EC9B0\">HasFactory<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">use<\/span><span style=\"color: #D4D4D4\"> Illuminate\\Foundation\\Auth\\<\/span><span style=\"color: #4EC9B0\">User<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">as<\/span><span style=\"color: #D4D4D4\"> Authenticatable;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">use<\/span><span style=\"color: #D4D4D4\"> Illuminate\\Notifications\\<\/span><span style=\"color: #4EC9B0\">Notifiable<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #569CD6\">use<\/span><span style=\"color: #D4D4D4\"> Laravel\\Fortify\\<\/span><span style=\"color: #4EC9B0\">TwoFactorAuthenticatable<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">use<\/span><span style=\"color: #D4D4D4\"> Laravel\\Sanctum\\<\/span><span style=\"color: #4EC9B0\">HasApiTokens<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">class<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">User<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">extends<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">Authenticatable<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">{<\/span><\/span>\n<span class=\"line cbp-line-highlight\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">use<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">HasApiTokens<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #4EC9B0\">HasFactory<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #4EC9B0\">Notifiable<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #4EC9B0\">TwoFactorAuthenticatable<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #6A9955\">\/* The rest of the User Model code .. *\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">La s\u00e9curit\u00e9 de l&rsquo;application s&rsquo;am\u00e9liore avec la 2FA. Configurer des notifications de mot de passe \u00e0 usage unique (OTP) par e-mail ou SMS devient tr\u00e8s important. Ajouter facilement votre apllication \u00e0 Google Authenticator ou Microsoft Authenticator.<\/p>\n\n\n\nngg_shortcode_0_placeholder\n","protected":false},"excerpt":{"rendered":"<p>La s\u00e9curit\u00e9 de l&rsquo;application s&rsquo;am\u00e9liore avec la 2FA. Configurer des notifications de mot de passe \u00e0 usage unique (OTP) par e-mail ou SMS devient tr\u00e8s important. Ajouter facilement votre apllication \u00e0 Google Authenticator ou Microsoft Authenticator.<\/p>\n","protected":false},"author":1,"featured_media":576,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[50,9,8,10],"tags":[13,11,14],"class_list":["post-572","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api","category-backend","category-laravel","category-php","tag-backend","tag-laravel","tag-php"],"_links":{"self":[{"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/posts\/572","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/comments?post=572"}],"version-history":[{"count":2,"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/posts\/572\/revisions"}],"predecessor-version":[{"id":780,"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/posts\/572\/revisions\/780"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/media\/576"}],"wp:attachment":[{"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/media?parent=572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/categories?post=572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/portfolio.articole-smart.eu\/index.php\/wp-json\/wp\/v2\/tags?post=572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}