记录 grafana登录 从 go 迁移到 php
生活随笔
收集整理的這篇文章主要介紹了
记录 grafana登录 从 go 迁移到 php
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
最近一直在搞grafana 嵌入到web應用(laravel寫的)中,于是乎,看了一下它的登錄,其實是想用grafana的user表,分享如下。
首先記錄下,grafana 密碼是如何校驗的
grafana 密碼加密:PBKDF2(password, salt, 10000, 50, sha256.new)
php pbkdf2加密: hash_pbkdf2 ( ‘sha256’ , string $password , string $salt , 10000, 100);(不知道為啥第五個參數長度是100 就與 grafana的密碼加密方式匹配成功的)
參考 這篇文章 修改了laravel登錄方式
public function validateCredentials(Authenticatable $user, array $credentials){$plain = $credentials['password']; // 輸入的密碼$authPassword = $user->getAuthPassword(); // DB中的密碼和salt$inputPwd = grafana_PBKDF2($plain, $authPassword['salt']);$isValidate = ($inputPwd == $authPassword['password']);// 設置cookie$user->setGrafanaCookie();return $isValidate;}這一塊兒, 設置cookie, 遇到了個坑, 在PHP 中找到了
openssl_encrypt($hash, 'aes-256-gcm', $Key, OPENSSL_RAW_DATA, $IV = random_bytes(16), $Tag, '', 16) . $IV . $Tag; 這個,但是不會用啊, 還請各位大佬指導
參考鏈接有:
https://github.com/hprose/hprose-golang/issues/31
https://stackoverflow.com/questions/52599885/aes-256-gcm-decryption-from-php-to-golang
https://github.com/Spomky-Labs/php-aes-gcm
總結
以上是生活随笔為你收集整理的记录 grafana登录 从 go 迁移到 php的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: deepin 安装 kvm-manage
- 下一篇: prometheus rfc3339