src/snac/server/database/SQL.php
/**
     * Select Key Data by Key
     *
     * This method is used for authentication purposes, when we have the clear-text key
     * (which can NOT be used to index the database) and the label (which can be used
     * to index the database).  This method gets all keys matching the provided label (which
     * may be multiple).  Then, for each key, it uses PHP's built-in cryptographically
     * secure password verifier to see if the encrypted key in the database matches the
     * provided clear-text key.  If the keys match, it returns that row's data (including
     * userID, expires, and generated times).
     *
     * WARNING: No part of this method should be logged on production! It contains clear-text
     * API keys.
     *
     * @param string $key The CLEAR-TEXT API Key
     * @param string $label The label for the API Key
     * @return string[]|null The associated data for the key (userid, expires, generated) or null if not found
     */
Select Key Data by Key
This method is used for authentication purposes, when we have the clear-text key
(which can NOT be used to index the database) and the label (which can be used
to index the database).  This method gets all keys matching the provided label (which
may be multiple).  Then, for each key, it uses PHP's built-in cryptographically
secure password verifier to see if the encrypted key in the database matches the
provided clear-text key.  If the keys match, it returns that row's data (including
userID, expires, and generated times).

No part of this method should be logged on production. It contains clear-text
API keys.

@param string $key The CLEAR-TEXT API Key
@param string $label The label for the API Key
@return string[]|null The associated data for the key (userid, expires, generated) or null if not found
Select Key Data by Key This method is used for authentication purposes when we have the clear - text key ( which can NOT be used to index the database ) and the label ( which can be used to index the database ) . This method gets all keys matching the provided label ( which may be multiple ) . Then for each key it uses PHP ' s built - in cryptographically secure password verifier to see if the encrypted key in the database matches the provided clear - text key . If the keys match it returns that row ' s data ( including userID expires and generated times ) . No part of this method should be logged on production . It contains clear - text API keys . @param string $key The CLEAR - TEXT API Key @param string $label The label for the API Key @return string [] |null The associated data for the key ( userid expires generated ) or null if not found
public function selectAPIKeyByKey($key, $label)
    {
        $result = $this->sdb->query("select * from api_keys where label = $1;", [$label]);
        while($row = $this->sdb->fetchrow($result))
        {
            if (password_verify($key, $row["key"]))
                return $row;
        }
        return null;
    }
public function selectAPIKeyByKey ( $ key , $ label ) { $ result = $ this -> sdb -> query ( " select * from api_keys where label = $1; " , [ $ label ] ) ; while ( $ row = $ this -> sdb -> fetchrow ( $ result ) ) { if ( password_verify ( $ key , $ row [ " key " ] ) ) return $ row ; } return null ; }
Select Key Data by Key
 This method is used for authentication purposes, when we have the clear-text key
 (which can NOT be used to index the database) and the label (which can be used
 to index the database).
Select Key Data by Key This method is used for authentication purposes when we have the clear - text key ( which can NOT be used to index the database ) and the label ( which can be used to index the database ) .