As mentioned over multiple posts in the forums that DF 2.0 will support Permanent Session Tokens. I decided to setup the public beta on a local VM. I have been able to install & safely copy my database(s) from 1.9.x to 2.0.
However, I feel there is a lack of documentation for 2.0, at the moment. My experience in programming Web technologies is limited, my background being mostly C# WinForms applications. Currently trying out an AngularJS Web Application + DF as a back end for a proof of concept application.
I would really appreciate if anyone could guide me with setting up DF 2.0 with Permanent Session Tokens.
I understand that 2.0 is still in beta and shouldnât be used for production apps, this is just a proof of concept and not a production application.
Hi, I have the same problem. But the solution of Mauro_Delazeri didnât do. I guess there is bug.
As a very hardcore solution that you could use at your own risk is to comment out some lines at
/vendor/tymon/jwt-auth/src/Validators/PayloadValidator.php
protected function validateTimestamps(array $payload)
{
if (isset($payload['nbf']) && Utils::timestamp($payload['nbf'])->isFuture()) {
throw new TokenInvalidException('Not Before (nbf) timestamp cannot be in the future', 400);
}
if (isset($payload['iat']) && Utils::timestamp($payload['iat'])->isFuture()) {
throw new TokenInvalidException('Issued At (iat) timestamp cannot be in the future', 400);
}
//THIS MAKES TOKENS LIVE FOREVER
//if (Utils::timestamp($payload['exp'])->isPast()) {
// throw new TokenExpiredException('Token has expired');
//}
return true;
}
For those who is interesed in details:
Looking through the code I found out that duration parameter has no effect at all (DreamFactory\Core\Resources\UserSessionResource.php:handleLogin), it is not processed. But there is âremember_meâ param that eventually is passed as â$foreverâ param to vendor/dreamfactory/df-core/src/Utility/JWTUtilities.php:makeJWTByUser.
Then a payload is created with âexpâ default claim and âforeverâ custom claim among others and finally save the token_map to DB. But the saving method looses the âforeverâ claim. It saves value and âexpâ, but not âforeverâ.
Now, here is the important thing to understand, the token you will get back is a forever token but it will expire after the default TTL (time-to-live) set in .env file (DF_JWT_TTL=60). However, you can always refresh that (forever) when it expires with the following API call.
PUT http://your-url/api/v2/user/session
You can pass the old expired token in request header (X-DreamFactory-Session-Token) or on url query string (?session_token)
I have set df_allow_forever_sessions=true in dreamfactory/htdocs/.env file but I do not get the property back when calling system/environment api. What am I doing wrong?
All upper case. Also, which version of bitnami image you are using?
If it still doesnât work using that config in .env file then you may have the older beta version. In that case make sure you have the the following line in âŚ/htdocs/config/df.php file.
Bitnami AWS images have the Bitnami stack installed in /opt/bitnami
This makes the path to the DreamFactory portion of the stack /opt/bitnami/apps/dreamfactory/htdocs
In case anyone is like me and is running dreamfactory on Openshift, the path to get to the .env file is ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/df.
I simply had to ssh into the application, navigate to the file, and then was able to add the line DF_ALLOW_FOREVER_SESSIONS=true to the .env file using VIM (or your editor of choice).
After doing this went to the api docs as mentioned above and confirmed that the setting was updated.
I changed in df.php allow_foreserver_sessions to true .
did run :
php artisan config:clear
php artisan cache:clear
~/apps/dreamfactory/htdocs$ sudo service bitnami restart
/opt/bitnami/config/monit/conf.d/nginx.conf:3: Warning: Program does not exist: â/opt/bitnami/nginx/scripts/ctl.shâ
/opt/bitnami/config/monit/conf.d/nginx.conf:4: Warning: Program does not exist: '/opt/bitnami/nginx/scripts/ctl.shâ
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd stopped
/opt/bitnami/php/scripts/ctl.sh : php-fpm stopped
160404 11:30:32 mysqld_safe mysqld from pid file /opt/bitnami/mysql/data/mysqld.pid ended
/opt/bitnami/mysql/scripts/ctl.sh : mysql stopped
160404 11:30:37 mysqld_safe Logging to â/opt/bitnami/mysql/data/mysqld.logâ.
160404 11:30:37 mysqld_safe Starting mysqld.bin daemon with databases from /opt/bitnami/mysql/data
/opt/bitnami/mysql/scripts/ctl.sh : mysql started at port 3306
/opt/bitnami/mongodb/scripts/ctl.sh : mongodb stopped
/opt/bitnami/mongodb/scripts/ctl.sh : mongodb started at port 27017
/opt/bitnami/php/scripts/ctl.sh : php-fpm started
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd started at port 80
/opt/bitnami/config/monit/conf.d/nginx.conf:3: Warning: Program does not exist: â/opt/bitnami/nginx/scripts/ctl.shâ
/opt/bitnami/config/monit/conf.d/nginx.conf:4: Warning: Program does not exist: â/opt/bitnami/nginx/scripts/ctl.shâ
Flushed system cache.
the api api/v2/system/environment returns âallow_forever_sessionsâ:false
I donât know if I am missing a step, but I cannot find an .env file anywhere in my install directory? Can someone steer me in the right direction? My DF instance is installed on an Ubuntu server.
Hi, I just launched a standalone (non-bitnami) ubuntu 14.04 nginx with SSL - took me a good day to get it right and saw your post looking for the same thing.
The .env file is a hidden file in your . for me it was /home/user/df2 htdocs does not exist on a standalone.
Couple of tips.
sftp to your server with FileZilla ~ it will show you the hidden files
use find / -name <directory> -type d from command line to search your server for a directory
use find / -name <filename> -type f from command line to search your server for a file (wildcards accepted)
I also installed a non bitnami standalone of DF2 on my ubuntu 14.04 for almost 2 weeks now but this is what i have been getting as a response when trying to launch the platform on my browser
âSynchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end userâs experience. For more help http://xhr.spec.whatwg.org/1 app.ee90cd63.js:3:13186
GET XHR http://localhost/api/v2/system/environment1 [HTTP/1.1 404 Not Found 0ms]
uncaught exception: [object Object]â
I have tried many options on user management perhaps the user doesnot have necessary access rights to the public installation folder and given the appropriate rights. But i have just this issue âGET XHR http://localhost/api/v2/system/environment [HTTP/1.1 404 Not Found 0ms]uncaught exception: [object Object];â as a major problem; can you please shed more light into how you were able to make it work and perhaps share some nginx configuration files.