簡體   English   中英

OAuth2.0 服務器授權類型用戶憑據密碼未加密

[英]OAuth2.0 server grant type user credentials password is not encrypted

我也在關注這個人關於oauth2-server-php-docs 在 OAuth2 服務器上存儲客戶端憑據的問題 雖然它為客戶端機密回答了一件事,但我想詢問用戶憑據。 檢查oauth2-server-php-docs 中的以下代碼示例:

// create some users in memory
$users = array('bshaffer' => array('password' => 'brent123', 'first_name' => 'Brent', 'last_name' => 'Shaffer'));

// create a storage object
$storage = new OAuth2\Storage\Memory(array('user_credentials' => $users));

// create the grant type
$grantType = new OAuth2\GrantType\UserCredentials($storage);

// add the grant type to your OAuth server
$server->addGrantType($grantType);

它說用戶憑據將存儲在內存中,並且沒有說明密碼加密。 這是我的用例——我已經將用戶憑據存儲在 MySQL 中,並使用 PHP password_hash() 加密了密碼。 那么如果 $user['bshaffer']['password'] 只是一個純文本,我如何匹配或使用 $storage = new OAuth2\\Storage\\Memory() 行?

我也有這個疑問。 但是,如果您閱讀文檔中的注釋,就在您提到的代碼片段下方,它會說:

注意:用戶存儲是針對每個應用程序高度定制的,因此強烈建議您使用 OAuth2\\Storage\\UserCredentialsInterface 實現自己的存儲

我認為我們可以使用“OAuth2\\Storage\\UserCredentialsInterface”接口為用戶模型實現我們自己的用戶存儲。

我通過擁有自己的網絡架構並擴展實現用戶定義的 password_verify() 的 Pdo 存儲對象來做到這一點。 所以我對這個做了什么我創建了 mytoken.php,它接收來自前端請求的帖子,然后使用 AUTH 用戶和密碼(client_secret)再次向 127.0.0.1 發送一個請求到 token.php。 我這樣做是為了不從前端請求發送 client_secret 。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM