SCL

@scl

Prime membership

Joined on Aug 17, 2016

  • 參考https://www.reddit.com/r/Nix/comments/11ynxa5/every_macos_update_needs_me_to_rerun_the_nix/?rdt=55449 sudo vi /etc/zshrc sudo vi /etc/bashrc if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' fi
     Like  Bookmark
  • 前言 本文主要分享,我如何採用Docker的方式進行Let's Encrypt憑證申請,Let's Encrypt有相當多種類的ACME Client,我將使用官方推廌Certbot(ACME Client)做說明。並且使用docker的方式來執行ACME Client。這樣做對筆者來說,有兩個好處: 一、我不需要在主機端(host),使用最高權限(root),跑certbot程式,也不需安裝相關執行Client的Python環境。 二、貼上指令,自動下載Client並執行,然後取得憑證,當您理解docker指令及certbot參數後,這將會是非常簡易的一件事情。** Dockerfile 再開始前,我們先來看看Certbot所提供的Dockerfile設定。理解Dockerfile的設定,有助於我們了解等下要執行指令的目地,所以我們來稍微看看吧。Dockerhub的位置,請參看這裡:https://hub.docker.com/r/certbot/certbot
     Like  Bookmark
  • sudo yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm sudo yum install -y mysql-community-client As of 2022, you are required to import the latest GPG key using: sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 Install MySQL 8.0 client on Amazon Linux 2 sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm sudo yum install -y mysql-community-client Install MySQL 5.7 Server on Amazon Linux 2 sudo yum update -y
     Like  Bookmark
  • 登入SSH,並執行下面程序 #檢查備份設定 sudo -i cat /usr/syno/etc/synobackup.conf #查看錯誤原因 cd /volume1/@img_bkp_cache/google_drive_* cd *.hbk cat Guard/detect/error.log
     Like  Bookmark
  • 參考資料 https://laravel.com/docs/8.x/rate-limiting 在config/fortify.php中設定限制所使用的名稱 /* |-------------------------------------------------------------------------- | Rate Limiting |-------------------------------------------------------------------------- | | By default, Fortify will throttle logins to five requests per minute for | every email and IP address combination. However, if you would like to
     Like  Bookmark
  • Laravel 本身已實現了登入失敗次數限制的功能。在使用 Laravel 的登入驗證時,登入失敗次數限制預設是: 失敗5次,1分鐘後 才可再次登入 若要設定: 失敗5次,15分鐘後 才可再次登入 說明:
     Like  Bookmark
  • reCAPTCHA token的有限時間只有2分鐘 reCAPTCHA tokens expire after two minutes. If you're protecting an action with reCAPTCHA, make sure to call execute when the user takes the action rather than on page load. 處理方式 1 <form> <input type="hidden" name="recaptcha" id="recaptcha"> <button>Submit</button> </form>
     Like  Bookmark
  • Issue Solved: after adding this code to my composer.json "@php artisan vendor:publish --force --tag=livewire:assets --ansi" To keep the assets up-to-date and avoid issues in future updates, we highly recommend adding the command to the post-autoload-dump scripts in your composer.json file: { "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
     Like  Bookmark
  • CSRF 跨站請求偽造 是一種常見的 Web 攻擊方式,通常情況下會在 Form 表單頁面增加 CSRF Token 來保護項目安全。 CSRF 例子 Laravel 中使用時非常方便的,中間件會自動的驗證,只有 CSRF Token 正確才能提交表單。 $ php artisan make:auth routes/web.php Route::group(['middleware' => 'auth'], function() {
     Like  Bookmark
  • In app/Exceptions/Handler.php replace this: public function render($request, Exception $e) { if ($e instanceof \Illuminate\Session\TokenMismatchException) { return redirect()->back()->withInput()->with('token', csrf_token()); } return parent::render($request, $e); }
     Like  Bookmark
  • Facade Usage 手動操作範例 GoogleReCaptchaV3::setAction($action)->verifyResponse($value,$ip = null); GoogleReCaptchaV3::verifyResponse($value,$ip)->getMessage(); GoogleReCaptchaV3::verifyResponse($value)->isSuccess(); GoogleReCaptchaV3::verifyResponse($value)->toArray(); GoogleReCaptchaV3::verifyResponse(
     Like  Bookmark
  • 新增自訂的忘記密碼頁面及重設密碼呼叫函式 #/app/Providers/FortifyServiceProvider.php public function boot() { use App\Actions\Fortify\ResetUserPassword; ... #自訂的忘記密碼頁面
     Like  Bookmark
  • Laravel 的 Session 並非使用 PHP 原生 Session 機制,而是使用自己的 Session 機制,所以,要調整存活時間等相關設定時,不是在 php.ini 裡面設定,而是要在 config/session.php 中設定,設定方式如下: Session 的存活時間 #Session 的存活時間(分鐘): #先找 `.env` 的 `SESSION_LIFETIME` 值,如果沒定義就用120分鐘 #config/session.php 'lifetime' => env('SESSION_LIFETIME', 120), 當關閉瀏覽器時 清除 Session
     Like  Bookmark
  • 方案一 在 config/database.php 設定檔中設定MySQL的模式,而不是直接關掉 strict ,這是比較正規安全的做法 // config/database.php 'connections' => [ //... 'mysql' => [ //... 'strict' => true,
     Like  Bookmark
  • onclick="confirm('請確認是否要送出?') || event.stopImmediatePropagation()" 如上方所示,將 wire:click 放在confirm後面,如果confirm 取消的話,則 wire:click 將不會執行。
     Like  Bookmark
  • 默認情況下,toSql 獲取到的 sql 裡面的參數使用 "?" 代替的,如下: DB::table('user')->where('id', 1)->toSql(); 獲取到的 sql 語句是: select * from `tb_user` where `id` = ? 有時候我們想要得到具體的語句,可以利用 builder 的 getBindings 方法:
     Like  Bookmark
  • laravel框架自身封裝的leftJoin方法如下: public function leftJoin($table, $first, $operator = null, $second = null) { return $this->join($table, $first, $operator, $second, ‘left’); } 瀏覽下 \vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php檔案,發現join方法可用實現自己想要的left join攜帶多引數。laravel自身的join方法如下: public function join($table, $one, $operator = null, $two = null, $type = ‘inner’, $where = false)
     Like  Bookmark