1
0
Fork 0
mirror of synced 2024-06-01 10:29:48 +12:00

Improved docs

This commit is contained in:
Matej Baco 2022-06-17 11:25:28 +02:00
parent 11909a25cb
commit 62ec121a5e
21 changed files with 70 additions and 28 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -99,7 +99,7 @@ App::post('/v1/users')
});
App::post('/v1/users/import/bcrypt')
->desc('Create User with BCrypt Password')
->desc('Create User with Bcrypt Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
->label('scope', 'users.write')
@ -112,7 +112,7 @@ App::post('/v1/users/import/bcrypt')
->label('sdk.response.model', Response::MODEL_USER)
->param('userId', '', new CustomId(), 'User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
->param('email', '', new Email(), 'User email.')
->param('password', '', new Password(), 'User password hashed using BCrypt.')
->param('password', '', new Password(), 'User password hashed using Bcrypt.')
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
->inject('response')
->inject('dbForProject')
@ -241,20 +241,20 @@ App::post('/v1/users/import/phpass')
});
App::post('/v1/users/import/scrypt')
->desc('Create User with SCrypt Password')
->desc('Create User with Scrypt Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
->label('scope', 'users.write')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'users')
->label('sdk.method', 'createSCryptUser')
->label('sdk.method', 'createScryptUser')
->label('sdk.description', '/docs/references/users/create-scrypt-user.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_USER)
->param('userId', '', new CustomId(), 'User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
->param('email', '', new Email(), 'User email.')
->param('password', '', new Password(), 'User password hashed using SCrypt.')
->param('password', '', new Password(), 'User password hashed using Scrypt.')
->param('passwordSalt', '', new Text(128), 'Optional salt used to hash password.', true)
->param('passwordCpu', '', new Integer(), 'Optional CPU cost used to hash password.', true)
->param('passwordMemory', '', new Integer(), 'Optional memory cost used to hash password.', true)
@ -295,20 +295,20 @@ App::post('/v1/users/import/scrypt')
});
App::post('/v1/users/import/scrypt-modified')
->desc('Create User with SCrypt Modified Password')
->desc('Create User with Scrypt Modified Password')
->groups(['api', 'users'])
->label('event', 'users.[userId].create')
->label('scope', 'users.write')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'users')
->label('sdk.method', 'createSCryptModifiedUser')
->label('sdk.method', 'createScryptModifiedUser')
->label('sdk.description', '/docs/references/users/create-scrypt-modified-user.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_USER)
->param('userId', '', new CustomId(), 'User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
->param('email', '', new Email(), 'User email.')
->param('password', '', new Password(), 'User password hashed using SCrypt Modified.')
->param('password', '', new Password(), 'User password hashed using Scrypt Modified.')
->param('passwordSalt', '', new Text(128), 'Salt used to hash password.')
->param('passwordSaltSeparator', '', new Text(128), 'Salt separator used to hash password.')
->param('passwordSignerKey', '', new Text(128), 'Signer key used to hash password.')

View file

@ -0,0 +1 @@
Create a new user. Password entered must be hashed with [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint if you want to import plain text password.

View file

@ -0,0 +1 @@
Create a new user. Password entered must be hashed with [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint if you want to import plain text password.

View file

@ -0,0 +1 @@
Create a new user. Password entered must be hashed with [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint if you want to import plain text password.

View file

@ -0,0 +1 @@
Create a new user. Password entered must be hashed with [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint if you want to import plain text password.

View file

@ -0,0 +1 @@
Create a new user. Password entered must be hashed with [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint if you want to import plain text password.

View file

@ -0,0 +1 @@
Create a new user. Password entered must be hashed with [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint if you want to import plain text password.

View file

@ -0,0 +1 @@
Create a new user. Password entered must be hashed with [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint if you want to import plain text password.

View file

@ -5121,6 +5121,11 @@
/**
* Create User with Argon2 Password
*
* Create a new user. Password entered must be hashed with
* [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST
* /users](/docs/server/users#usersCreate) endpoint if you want to import
* plain text password.
*
*
* @param {string} userId
* @param {string} email
@ -5159,7 +5164,12 @@
}, payload);
}),
/**
* Create User with BCrypt Password
* Create User with Bcrypt Password
*
* Create a new user. Password entered must be hashed with
* [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST
* /users](/docs/server/users#usersCreate) endpoint if you want to import
* plain text password.
*
*
* @param {string} userId
@ -5201,6 +5211,11 @@
/**
* Create User with MD5 Password
*
* Create a new user. Password entered must be hashed with
* [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST
* /users](/docs/server/users#usersCreate) endpoint if you want to import
* plain text password.
*
*
* @param {string} userId
* @param {string} email
@ -5241,6 +5256,11 @@
/**
* Create User with PHPass Password
*
* Create a new user. Password entered must be hashed with
* [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST
* /users](/docs/server/users#usersCreate) endpoint if you want to import
* plain text password.
*
*
* @param {string} userId
* @param {string} email
@ -5279,7 +5299,12 @@
}, payload);
}),
/**
* Create User with SCrypt Password
* Create User with Scrypt Password
*
* Create a new user. Password entered must be hashed with
* [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST
* /users](/docs/server/users#usersCreate) endpoint if you want to import
* plain text password.
*
*
* @param {string} userId
@ -5294,7 +5319,7 @@
* @throws {AppwriteException}
* @returns {Promise}
*/
createSCryptUser: (userId, email, password, passwordSalt, passwordCpu, passwordMemory, passwordParallel, passwordLength, name) => __awaiter(this, void 0, void 0, function* () {
createScryptUser: (userId, email, password, passwordSalt, passwordCpu, passwordMemory, passwordParallel, passwordLength, name) => __awaiter(this, void 0, void 0, function* () {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
@ -5339,7 +5364,12 @@
}, payload);
}),
/**
* Create User with SCrypt Modified Password
* Create User with Scrypt Modified Password
*
* Create a new user. Password entered must be hashed with [Scrypt
* Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc)
* algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint
* if you want to import plain text password.
*
*
* @param {string} userId
@ -5352,7 +5382,7 @@
* @throws {AppwriteException}
* @returns {Promise}
*/
createSCryptModifiedUser: (userId, email, password, passwordSalt, passwordSaltSeparator, passwordSignerKey, name) => __awaiter(this, void 0, void 0, function* () {
createScryptModifiedUser: (userId, email, password, passwordSalt, passwordSaltSeparator, passwordSignerKey, name) => __awaiter(this, void 0, void 0, function* () {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
@ -5402,6 +5432,11 @@
/**
* Create User with SHA Password
*
* Create a new user. Password entered must be hashed with
* [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use
* the [POST /users](/docs/server/users#usersCreate) endpoint if you want to
* import plain text password.
*
*
* @param {string} userId
* @param {string} email

View file

@ -5,7 +5,7 @@ namespace Appwrite\Auth\Hash;
use Appwrite\Auth\Hash;
/*
* BCrypt accepted options:
* Bcrypt accepted options:
* int cost
* string? salt; auto-generated if empty
*

View file

@ -5,7 +5,7 @@ namespace Appwrite\Auth\Hash;
use Appwrite\Auth\Hash;
/*
* SCrypt accepted options:
* Scrypt accepted options:
* string? salt; auto-generated if empty
* int costCpu
* int costMemory

View file

@ -5,7 +5,7 @@ namespace Appwrite\Auth\Hash;
use Appwrite\Auth\Hash;
/*
* This is SCrypt hash with some additional steps added by Google.
* This is Scrypt hash with some additional steps added by Google.
*
* string salt
* string saltSeparator

View file

@ -9,7 +9,7 @@ class AlgoArgon2 extends Model
{
public function __construct()
{
// No options if imported. If hashed by Appwrite, followign configuration is available:
// No options if imported. If hashed by Appwrite, following configuration is available:
$this
->addRule('memoryCost', [
'type' => self::TYPE_INTEGER,

View file

@ -44,7 +44,7 @@ class AlgoScrypt extends Model
*/
public function getName(): string
{
return 'AlgoSCrypt';
return 'AlgoScrypt';
}
/**

View file

@ -38,7 +38,7 @@ class AlgoScryptModified extends Model
*/
public function getName(): string
{
return 'AlgoSCryptModified';
return 'AlgoScryptModified';
}
/**

View file

@ -75,7 +75,7 @@ trait UsersBase
'userId' => 'bcrypt',
'email' => 'bcrypt@appwrite.io',
'password' => '$2a$15$xX/myGbFU.ZSKHSi6EHdBOySTdYm8QxBLXmOPHrYMwV0mHRBBSBOq', // appwrite (15 rounds)
'name' => 'BCrypt User',
'name' => 'Bcrypt User',
]);
$this->assertEquals($res['headers']['status-code'], 201);
@ -119,7 +119,7 @@ trait UsersBase
'userId' => 'scrypt',
'email' => 'scrypt@appwrite.io',
'password' => '3fdef49701bc4cfaacd551fe017283513284b4731e6945c263246ef948d3cf63b5d269c31fd697246085111a428245e24a4ddc6b64c687bc60a8910dbafc1d5b', // appwrite (salt appwrite, cpu 16384, memory 13, parallel 2, length 64)
'name' => 'SCrypt User',
'name' => 'Scrypt User',
'passwordSalt' => 'appwrite',
'passwordCpu' => 16384,
'passwordMemory' => 13,
@ -156,7 +156,7 @@ trait UsersBase
'userId' => 'scrypt-modified',
'email' => 'scrypt-modified@appwrite.io',
'password' => 'UlM7JiXRcQhzAGlaonpSqNSLIz475WMddOgLjej5De9vxTy48K6WtqlEzrRFeK4t0COfMhWCb8wuMHgxOFCHFQ==', // appwrite
'name' => 'SCrypt Modified User',
'name' => 'Scrypt Modified User',
'passwordSalt' => 'UxLMreBr6tYyjQ==',
'passwordSaltSeparator' => 'Bw==',
'passwordSignerKey' => 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==',

View file

@ -115,14 +115,14 @@ class AuthTest extends TestCase
$this->assertEquals(true, Auth::passwordVerify($plain, $generatedHash, 'argon2'));
$this->assertEquals(true, Auth::passwordVerify($plain, $hash, 'argon2'));
// SCrypt
// Scrypt
$plain = 'some-scrypt-password';
$hash = '2bc477f4160e7dc0e6bc6849ffa38a7062fec3800d937ce251cdf552609b94919c623cd07cc36ad600bc8caea8399e6f815a6d7ed96995d495ed70890d359d6d';
$generatedHash = Auth::passwordHash($plain, 'scrypt');
$this->assertEquals(true, Auth::passwordVerify($plain, $generatedHash, 'scrypt'));
$this->assertEquals(true, Auth::passwordVerify($plain, $hash, 'scrypt', ['length' => 64, 'costCpu' => 16384, 'costMemory' => 12, 'costParallel' => 2]));
// SCryptModified tested are in provider-specific tests below
// ScryptModified tested are in provider-specific tests below
/*
Provider-specific tests, ensuring functionality of specific use-cases