4D v16.3On 4D Mobile Authentication database method |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
On 4D Mobile Authentication database method
On 4D Mobile Authentication database method
The On 4D Mobile Authentication database method provides you with a custom way of controlling the opening of 4D Mobile sessions (via REST) on 4D. This database method is mainly intended for filtering connections when setting up a connection between a Wakanda Server and 4D. When the request to open a 4D Mobile session comes from Wakanda Server by means of the mergeOutsideCatalog() method (general case), the connection identifiers are provided in the header of the request. The On 4D Mobile Authentication database method is called so that you can evaluate these identifiers. You can use the list of users for the 4D database or you can use your own table of identifiers. Important: When On 4D Mobile Authentication database method is defined (i.e. when it contains code), 4D fully delegates control of 4D Mobile requests to it: any setting made using the "Read/Write" menu on the Web/4D Mobile page of the Database Settings is ignored (see the Design Reference manual). The database method receives two parameters ($1 and $2) of the Text type and a Boolean ($3), passed by 4D, and returns a Boolean, $0. You must declare these parameters as follows: //On 4D Mobile Authentication database method $1 contains the user name and $2 the password used for the connection. The password ($2) can be received either in clear or hashed form, depending mode used by the request. This mode is indicated by the $3 parameter to enable you to perform the appropriate processing:
When a 4D Mobile connection request comes from Wakanda Server, the password is always sent in hashed form. You must check the identifiers of the 4D Mobile connection in the database method. Usually, you check the name and password using a custom user table. If the identifiers are valid, pass True in $0. The request is then accepted; 4D executes it and returns the result in JSON. If the user is referenced in the list of 4D users of the database, you can check the password directly by means of the following statement: $0:=Validate password($1;$2;$3) The Validate password command has been extended to accept a user name as first parameter as well as an optional parameter indicating whether the password is expressed in hashed form. If you want to use your own list of users external to the 4D database list, you can save their passwords in hashed form using the same algorithm as that used by Wakanda Server when sending the connection request to the On 4D Mobile Authentication database method in $2. To hash a password using this method, you can write: $HashedPasswd :=Generate digest($ClearPasswd ;4D digest) The Generate digest command accepts 4D digest as a hashing algorithm, corresponding to the method used by 4D for its internal management of passwords. This example only accepts the "admin" user with the password "123" that does not match a 4D user: //On 4D Mobile Authentication database method This example of the On 4D Mobile Authentication database method checks that the connection request comes from one of the two authorized Wakanda servers, saved in the users of the 4D database: C_TEXT($1;$2)
|
PROPERTIES
Product: 4D
HISTORY
Created: 4D v14 ARTICLE USAGE
4D Language Reference ( 4D v16) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||