记录 grafana登录 从 go 迁移到 php
生活随笔
收集整理的這篇文章主要介紹了
记录 grafana登录 从 go 迁移到 php
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
最近一直在搞grafana 嵌入到web應(yīng)用(laravel寫的)中,于是乎,看了一下它的登錄,其實(shí)是想用grafana的user表,分享如下。
首先記錄下,grafana 密碼是如何校驗(yàn)的
grafana 密碼加密:PBKDF2(password, salt, 10000, 50, sha256.new)
php pbkdf2加密: hash_pbkdf2 ( ‘sha256’ , string $password , string $salt , 10000, 100);(不知道為啥第五個(gè)參數(shù)長(zhǎng)度是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']);// 設(shè)置cookie$user->setGrafanaCookie();return $isValidate;}這一塊兒, 設(shè)置cookie, 遇到了個(gè)坑, 在PHP 中找到了
openssl_encrypt($hash, 'aes-256-gcm', $Key, OPENSSL_RAW_DATA, $IV = random_bytes(16), $Tag, '', 16) . $IV . $Tag; 這個(gè),但是不會(huì)用啊, 還請(qǐng)各位大佬指導(dǎo)
參考鏈接有:
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
總結(jié)
以上是生活随笔為你收集整理的记录 grafana登录 从 go 迁移到 php的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: deepin 安装 kvm-manage
- 下一篇: prometheus rfc3339