[pgadmin-hackers] pgAdmin 4 commit: Move security keys into the SQLite database, and auto

2016-10-19 Thread Dave Page
Move security keys into the SQLite database, and auto-generate them.

This avoids packagers having to deal with the issue, which can be
difficult if they need to cater for both server and desktop modes.

Fixes #1849

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=bc5cc964a3a67a0a5e367524c18e51266faf08f8

Modified Files
--
web/config.py | 16 +++-
web/pgAdmin4.py   | 12 -
web/pgadmin/__init__.py   | 31 +--
web/pgadmin/model/__init__.py |  9 ++-
web/setup.py  | 58 +--
5 files changed, 80 insertions(+), 46 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Dave Page
Patch applied.

Fahar, can you please test this thoroughly in desktop and server modes,
with both fresh and upgraded installations?

https://redmine.postgresql.org/issues/1849

Packagers: This change means that packages are no longer forced to create a
config_local.py file, and there is no longer any need to explicitly set
SECURITY_PASSWORD_SALT, SECURITY_KEY and CSRF_SESSION_KEY in the config (in
fact, they should be removed for new installations, if you have included
them in 1.0)

Thanks.

On Wed, Oct 19, 2016 at 6:46 AM, Ashesh Vashi  wrote:

> Hi Dave,
>
> On Sat, Oct 15, 2016 at 8:02 AM, Dave Page  wrote:
>
>> Hi
>>
>>
>> On Friday, October 14, 2016, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thursday, October 13, 2016, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
 Hi Dave,

 On Tue, Oct 11, 2016 at 9:10 PM, Dave Page  wrote:

> Hi Ashesh,
>
> Can you please review the attached patch, and apply if you're happy
> with it?
>
 Overall the patch looked good to me.
 But - I encounter an issue in 'web' mode, which wont happen with
 'runtime'.

 Steps for reproduction on existing pgAdmin 4 environment with 'web'
 mode.
 - Apply the patch
 - Start the pgAdmin4 application (stand alone application).
 - Open pgAdmin home page.
 - Log out (if already login).

 And, you will see an exception.

 I have figure out the issue with the patch.
 We were setting the SECURITY_PASSWORD_SALT, after initializing the
 Security object.
 Hence - it could not set the SECURITY_KEY, and SECURITY_PASSWORD_SALT
 properly.

>>>
>>> Hmm.
>>>
>>>

 I had moved the Security object initialization after fetching these
 configurations from the database.
 I have attached a addon patch for the same.

>>>
>>> OK, thanks.
>>>
>>>

 Now - I run into another issue.
 Because - the existing password was hashed using the old
 SECURITY_PASSWORD_SALT, I am no more able to login to pgAdmin 4.

 I think - we need to think about different strategy for upgrading the
 configuration file in the 'web' mode.
 I was thinking - we can store the existing security configurations in
 the database during upgrade process in 'web' mode.

>>>
>>> My concern with that is that we'll likely be storing the default config
>>> values in many cases, thus for those users, perpetuating the problem.
>>>
>>> I guess what we need to do is re-encrypt the password during the upgrade
>>> - however, that makes me think; we then have both the key and the encrypted
>>> passwords in the same database which is clearly not a good idea. Sigh...
>>> Needs more thought.
>>>
>>
>> OK, so I've been thinking about this and experimenting for a couple of
>> hours, as well as annoying the crap out of Magnus by thinking out loud in
>> his general direction, and it looks like this isn't a major problem as from
>> what I can see,  SECURITY_PASSWORD_SALT is (aside from really being a key
>> not a salt) not the only salting that's done.
>>
>> It looks like it's used system-wide as the key to generate an HMAC of the
>> users password, which is then passed to passlib which salts and hashes it.
>> I did some testing, and found that two users with the same password end up
>> with different hashes in the database, so clearly there is also per-user
>> salting happening. I also created two users, then dropped the database and
>> created the same user accounts with the same passwords again, and found
>> that the resulting hashes were different in both databases - thus there is
>> something else ensuring the hashes are unique across different
>> installations/databases.
>>
>> So, I believe we can do as you suggest and migrate existing values for
>> SECURITY_PASSWORD_SALT, given that there's clearly some other per user and
>> per installation/database salting going on anyway. New installations can
>> have the random value for SECURITY_PASSWORD_SALT.
>>
> We do not need to generate the random SECURITY_PASSWORD_SALT during
> upgrade mode, which was wrong added in my addon patch.
>
> Please find the updated patch.
>
> Otherwise - looks good to me.
> Please commit the new patch (if you're ok with the change).
>
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
>>
>> I don't believe SECURITY_KEY and CSRF_SESSION_KEY are issues either, as
>> they're used for purposes that are essentially ephemeral, and thus can be
>> changed during an upgrade.
>>
>> Adding Magnus as I'd appreciate any thoughts he may have.
>>
>> Patch attached - please review (Ashesh, but others too would be
>> appreciated)!
>>
>> Thanks.
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL C

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
Sure,

Will test this thoroughly after complete investigation.

Kind Regards,

On Wed, Oct 19, 2016 at 1:27 PM, Dave Page  wrote:

> Patch applied.
>
> Fahar, can you please test this thoroughly in desktop and server modes,
> with both fresh and upgraded installations?
>
> https://redmine.postgresql.org/issues/1849
>
> Packagers: This change means that packages are no longer forced to create
> a config_local.py file, and there is no longer any need to explicitly set
> SECURITY_PASSWORD_SALT, SECURITY_KEY and CSRF_SESSION_KEY in the config
> (in fact, they should be removed for new installations, if you have
> included them in 1.0)
>
> Thanks.
>
>
> On Wed, Oct 19, 2016 at 6:46 AM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Sat, Oct 15, 2016 at 8:02 AM, Dave Page  wrote:
>>
>>> Hi
>>>
>>>
>>> On Friday, October 14, 2016, Dave Page  wrote:
>>>
 Hi

 On Thursday, October 13, 2016, Ashesh Vashi <
 ashesh.va...@enterprisedb.com> wrote:

> Hi Dave,
>
> On Tue, Oct 11, 2016 at 9:10 PM, Dave Page  wrote:
>
>> Hi Ashesh,
>>
>> Can you please review the attached patch, and apply if you're happy
>> with it?
>>
> Overall the patch looked good to me.
> But - I encounter an issue in 'web' mode, which wont happen with
> 'runtime'.
>
> Steps for reproduction on existing pgAdmin 4 environment with 'web'
> mode.
> - Apply the patch
> - Start the pgAdmin4 application (stand alone application).
> - Open pgAdmin home page.
> - Log out (if already login).
>
> And, you will see an exception.
>
> I have figure out the issue with the patch.
> We were setting the SECURITY_PASSWORD_SALT, after initializing the
> Security object.
> Hence - it could not set the SECURITY_KEY, and SECURITY_PASSWORD_SALT
> properly.
>

 Hmm.


>
> I had moved the Security object initialization after fetching these
> configurations from the database.
> I have attached a addon patch for the same.
>

 OK, thanks.


>
> Now - I run into another issue.
> Because - the existing password was hashed using the old
> SECURITY_PASSWORD_SALT, I am no more able to login to pgAdmin 4.
>
> I think - we need to think about different strategy for upgrading the
> configuration file in the 'web' mode.
> I was thinking - we can store the existing security configurations in
> the database during upgrade process in 'web' mode.
>

 My concern with that is that we'll likely be storing the default config
 values in many cases, thus for those users, perpetuating the problem.

 I guess what we need to do is re-encrypt the password during the
 upgrade - however, that makes me think; we then have both the key and the
 encrypted passwords in the same database which is clearly not a good idea.
 Sigh... Needs more thought.

>>>
>>> OK, so I've been thinking about this and experimenting for a couple of
>>> hours, as well as annoying the crap out of Magnus by thinking out loud in
>>> his general direction, and it looks like this isn't a major problem as from
>>> what I can see,  SECURITY_PASSWORD_SALT is (aside from really being a key
>>> not a salt) not the only salting that's done.
>>>
>>> It looks like it's used system-wide as the key to generate an HMAC of
>>> the users password, which is then passed to passlib which salts and hashes
>>> it. I did some testing, and found that two users with the same password end
>>> up with different hashes in the database, so clearly there is also per-user
>>> salting happening. I also created two users, then dropped the database and
>>> created the same user accounts with the same passwords again, and found
>>> that the resulting hashes were different in both databases - thus there is
>>> something else ensuring the hashes are unique across different
>>> installations/databases.
>>>
>>> So, I believe we can do as you suggest and migrate existing values for
>>> SECURITY_PASSWORD_SALT, given that there's clearly some other per user and
>>> per installation/database salting going on anyway. New installations can
>>> have the random value for SECURITY_PASSWORD_SALT.
>>>
>> We do not need to generate the random SECURITY_PASSWORD_SALT during
>> upgrade mode, which was wrong added in my addon patch.
>>
>> Please find the updated patch.
>>
>> Otherwise - looks good to me.
>> Please commit the new patch (if you're ok with the change).
>>
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> 
>>
>>>
>>> I don't believe SECURITY_KEY and CSRF_SESSION_KEY are issues either, as
>>> they're used for purposes that are essentially ephemeral, and thus can be
>>> changed during an upgrade.
>>>
>>> Addin

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
Dave,

Testing Environment

Ubuntu 16.04 Linux 64:


pg-AdminIV Development Environment Setup for Ubuntu  :


1) Install GIT

sudo apt-get install git

2) Install pip3

sudo apt-get install python3-pip

3) Install virtualenv

sudo pip3 install virtualenv

4) install below dependency as it is required for psycopg2 & pycrypto module

sudo apt-get install libpq-dev

sudo apt-get install python3-dev

5) Create virtual environment

virtualenv -p python3 venv

6) Create mkdir Projects

7) Clone git repo in Projects

git clone http://git.postgresql.org/git/pgadmin4.git

8) activate virtual environment

source venv/bin/activate

9) Install modules

pip3 install -r requirements_py3.txt

*10) Edit the config.py file to config_local.py  resides in
Projects\pgAdmin4\web *

11)Now run setup.py file  (\Projects\pgAdmin4\web)
python setup.py

If user does not create config_local.py and do Python setup.py for new
Development then SECURITY_PASSWORD_SALT message is also displayed:

Here is the output:
-

python setup.py
pgAdmin 4 - Application Initialisation
==


The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
exist.
Entering initial setup mode...
NOTE: Configuring authentication for SERVER mode.


Enter the email address and password to use for the initial pgAdmin
user account:

Email address: fahar.ab...@enterprisedb.com
Password:
Retype password:
Traceback (most recent call last):
  File "setup.py", line 449, in 
do_setup(app)
  File "setup.py", line 96, in do_setup
password = encrypt_password(p1)
  File
"/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
line 150, in encrypt_password
signed = get_hmac(password).decode('ascii')
  File
"/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
line 108, in get_hmac
'set to "%s"' % _security.password_hash)
RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not be
None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
(venv) fahar@fahar-virtual-machine:~/Projects/pgadmin4/web$


Is this expected?

On Wed, Oct 19, 2016 at 1:37 PM, Fahar Abbas 
wrote:

> Sure,
>
> Will test this thoroughly after complete investigation.
>
> Kind Regards,
>
> On Wed, Oct 19, 2016 at 1:27 PM, Dave Page  wrote:
>
>> Patch applied.
>>
>> Fahar, can you please test this thoroughly in desktop and server modes,
>> with both fresh and upgraded installations?
>>
>> https://redmine.postgresql.org/issues/1849
>>
>> Packagers: This change means that packages are no longer forced to create
>> a config_local.py file, and there is no longer any need to explicitly set
>> SECURITY_PASSWORD_SALT, SECURITY_KEY and CSRF_SESSION_KEY in the config
>> (in fact, they should be removed for new installations, if you have
>> included them in 1.0)
>>
>> Thanks.
>>
>>
>> On Wed, Oct 19, 2016 at 6:46 AM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> On Sat, Oct 15, 2016 at 8:02 AM, Dave Page  wrote:
>>>
 Hi


 On Friday, October 14, 2016, Dave Page  wrote:

> Hi
>
> On Thursday, October 13, 2016, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Tue, Oct 11, 2016 at 9:10 PM, Dave Page  wrote:
>>
>>> Hi Ashesh,
>>>
>>> Can you please review the attached patch, and apply if you're happy
>>> with it?
>>>
>> Overall the patch looked good to me.
>> But - I encounter an issue in 'web' mode, which wont happen with
>> 'runtime'.
>>
>> Steps for reproduction on existing pgAdmin 4 environment with 'web'
>> mode.
>> - Apply the patch
>> - Start the pgAdmin4 application (stand alone application).
>> - Open pgAdmin home page.
>> - Log out (if already login).
>>
>> And, you will see an exception.
>>
>> I have figure out the issue with the patch.
>> We were setting the SECURITY_PASSWORD_SALT, after initializing the
>> Security object.
>> Hence - it could not set the SECURITY_KEY, and SECURITY_PASSWORD_SALT
>> properly.
>>
>
> Hmm.
>
>
>>
>> I had moved the Security object initialization after fetching these
>> configurations from the database.
>> I have attached a addon patch for the same.
>>
>
> OK, thanks.
>
>
>>
>> Now - I run into another issue.
>> Because - the existing password was hashed using the old
>> SECURITY_PASSWORD_SALT, I am no more able to login to pgAdmin 4.
>>
>> I think - we need to think about different strategy for upgrading the
>> configuration file in the 'web' mode.
>> I was thinking - we can store the existing security configurations in
>> the database during upgrade process in 'web' mode.
>>
>
> My concern with that is that we'll likely be storing the default
> config values in many cases, 

Re: [pgadmin-hackers] Setting up pgAdmin4 as a web application

2016-10-19 Thread Dave Page
Hi

On Tue, Oct 18, 2016 at 6:42 PM, Derek Ealy  wrote:
> I've been trying to get pgAdmin4 to work as a web app for a couple of days.
> I've finally figured out python, pip, wsgi, apache (I think). I can see from
> the logs that is failing when trying to select from the version table which
> I assume should be in the sqlite Db as opposed to my postgres instance.
>
> I've located my pgadmin4.db file and can see that has zero bytes in it.
>
> Here is the message that appears in my apache error log when I try to access
> the pgadmin4 website:
>
> OperationalError: (sqlite3.OperationalError) no such table: version [SQL:
> u'SELECT version.name AS version_name, version.value AS version_value
> \\nFROM version \\nWHERE version.name = ?\\n LIMIT ? OFFSET ?'] [parameters:
> ('ConfigDB', 1, 0)], referer: http://dbgsdev01.nw.loc/
>
> Any ideas how I can get this fixed?

I'll bet this is a permissions issue, with the webserver user account
being unable to properly write files where it needs to. On my test
system, I did something like the following:

- Stop the web server
- Set the following paths in config_local.py in the pgAdmin installation:

LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'

- My webserver is running as daemon:daemon - adjust the following to suit:

# mkdir /var/log/pgadmin4
# chown daemon:daemon /var/log/pgadmin4
# mkdir /var/lib/pgadmin4
# chown daemon:daemon /var/lib/pgadmin4

- Start the web server

That should allow the config database to be properly created in a
location that the webserver can access, and ensure the sessions,
storage and logs are similarly accessible.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
Here is the output of if we copy config_local.py and execute python setup.py
pgAdmin 4 - Application Initialisation
==


The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
exist.
Entering initial setup mode...
NOTE: Configuring authentication for SERVER mode.


Enter the email address and password to use for the initial pgAdmin
user account:

Email address: fahar.ab...@enterprisedb.com
Password:
Retype password:
Traceback (most recent call last):
  File "setup.py", line 449, in 
do_setup(app)
  File "setup.py", line 96, in do_setup
password = encrypt_password(p1)
  File
"/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
line 150, in encrypt_password
signed = get_hmac(password).decode('ascii')
  File
"/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
line 108, in get_hmac
'set to "%s"' % _security.password_hash)
RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not be
None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
python setup.py
pgAdmin 4 - Application Initialisation
==

User can not do any setup for web based now.


The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
exist.
Entering initial setup mode...
NOTE: Configuring authentication for SERVER mode.


Enter the email address and password to use for the initial pgAdmin
user account:

Email address: fahar.ab...@enterprisedb.com
Password:
Retype password:
Traceback (most recent call last):
  File "setup.py", line 449, in 
do_setup(app)
  File "setup.py", line 96, in do_setup
password = encrypt_password(p1)
  File
"/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
line 150, in encrypt_password
signed = get_hmac(password).decode('ascii')
  File
"/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
line 108, in get_hmac
'set to "%s"' % _security.password_hash)
RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not be
None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"

On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas 
wrote:

> Dave,
>
> Testing Environment
>
> Ubuntu 16.04 Linux 64:
> 
>
> pg-AdminIV Development Environment Setup for Ubuntu  :
>
>
> 1) Install GIT
>
> sudo apt-get install git
>
> 2) Install pip3
>
> sudo apt-get install python3-pip
>
> 3) Install virtualenv
>
> sudo pip3 install virtualenv
>
> 4) install below dependency as it is required for psycopg2 & pycrypto
> module
>
> sudo apt-get install libpq-dev
>
> sudo apt-get install python3-dev
>
> 5) Create virtual environment
>
> virtualenv -p python3 venv
>
> 6) Create mkdir Projects
>
> 7) Clone git repo in Projects
>
> git clone http://git.postgresql.org/git/pgadmin4.git
>
> 8) activate virtual environment
>
> source venv/bin/activate
>
> 9) Install modules
>
> pip3 install -r requirements_py3.txt
>
> *10) Edit the config.py file to config_local.py  resides in
> Projects\pgAdmin4\web *
>
> 11)Now run setup.py file  (\Projects\pgAdmin4\web)
> python setup.py
>
> If user does not create config_local.py and do Python setup.py for new
> Development then SECURITY_PASSWORD_SALT message is also displayed:
>
> Here is the output:
> -
>
> python setup.py
> pgAdmin 4 - Application Initialisation
> ==
>
>
> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
> exist.
> Entering initial setup mode...
> NOTE: Configuring authentication for SERVER mode.
>
>
> Enter the email address and password to use for the initial pgAdmin
> user account:
>
> Email address: fahar.ab...@enterprisedb.com
> Password:
> Retype password:
> Traceback (most recent call last):
>   File "setup.py", line 449, in 
> do_setup(app)
>   File "setup.py", line 96, in do_setup
> password = encrypt_password(p1)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 150, in encrypt_password
> signed = get_hmac(password).decode('ascii')
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 108, in get_hmac
> 'set to "%s"' % _security.password_hash)
> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not be
> None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
> (venv) fahar@fahar-virtual-machine:~/Projects/pgadmin4/web$
>
>
> Is this expected?
>
> On Wed, Oct 19, 2016 at 1:37 PM, Fahar Abbas  > wrote:
>
>> Sure,
>>
>> Will test this thoroughly after complete investigation.
>>
>> Kind Regards,
>>
>> On Wed, Oct 19, 2016 at 1:27 PM, Dave Page  wrote:
>>
>>> Patch applied.
>>>
>>> Fahar, can you please test this thoroughly in desktop and server modes,
>>> with both fresh and upgraded installations?
>>>
>>> https://redmine.postgresql.org/issues/1849
>>>
>>> Packagers: This chan

[pgadmin-hackers] pgAdmin 4 commit: Resolved - Integer type of preferences are not update

2016-10-19 Thread Ashesh Vashi
Resolved - Integer type of preferences are not updated

Reason: IntegerControl assumes the model, passed to it, would always has 
errorModel variable set properly.

In order to resolve it, now using pgBrowser.DataModel instead of 
Backbone.Model, which initialize the errorModel by default.

Fixes #1868

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=b17eb157423043352a948b38e3eb703cb45c5698

Modified Files
--
web/pgadmin/preferences/templates/preferences/preferences.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
On Wed, Oct 19, 2016 at 3:55 PM, Ashesh Vashi  wrote:

> Hi Fahar,
>
> Please log the case on redmine.
>
https://redmine.postgresql.org/issues/1871

> Please find the attached patch, please apply it locally, and test it.
>
> And, please update the case, and this mail chain accordingly.
>
> Sure Will test the patch and update the status accordingly.

> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas  > wrote:
>
>> Here is the output of if we copy config_local.py and execute python
>> setup.py
>> pgAdmin 4 - Application Initialisation
>> ==
>>
>>
>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
>> exist.
>> Entering initial setup mode...
>> NOTE: Configuring authentication for SERVER mode.
>>
>>
>> Enter the email address and password to use for the initial pgAdmin
>> user account:
>>
>> Email address: fahar.ab...@enterprisedb.com
>> Password:
>> Retype password:
>> Traceback (most recent call last):
>>   File "setup.py", line 449, in 
>> do_setup(app)
>>   File "setup.py", line 96, in do_setup
>> password = encrypt_password(p1)
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 150, in encrypt_password
>> signed = get_hmac(password).decode('ascii')
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 108, in get_hmac
>> 'set to "%s"' % _security.password_hash)
>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>> python setup.py
>> pgAdmin 4 - Application Initialisation
>> ==
>>
>> User can not do any setup for web based now.
>>
>>
>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
>> exist.
>> Entering initial setup mode...
>> NOTE: Configuring authentication for SERVER mode.
>>
>>
>> Enter the email address and password to use for the initial pgAdmin
>> user account:
>>
>> Email address: fahar.ab...@enterprisedb.com
>> Password:
>> Retype password:
>> Traceback (most recent call last):
>>   File "setup.py", line 449, in 
>> do_setup(app)
>>   File "setup.py", line 96, in do_setup
>> password = encrypt_password(p1)
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 150, in encrypt_password
>> signed = get_hmac(password).decode('ascii')
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 108, in get_hmac
>> 'set to "%s"' % _security.password_hash)
>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>>
>> On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
>> fahar.ab...@enterprisedb.com> wrote:
>>
>>> Dave,
>>>
>>> Testing Environment
>>>
>>> Ubuntu 16.04 Linux 64:
>>> 
>>>
>>> pg-AdminIV Development Environment Setup for Ubuntu  :
>>>
>>>
>>> 1) Install GIT
>>>
>>> sudo apt-get install git
>>>
>>> 2) Install pip3
>>>
>>> sudo apt-get install python3-pip
>>>
>>> 3) Install virtualenv
>>>
>>> sudo pip3 install virtualenv
>>>
>>> 4) install below dependency as it is required for psycopg2 & pycrypto
>>> module
>>>
>>> sudo apt-get install libpq-dev
>>>
>>> sudo apt-get install python3-dev
>>>
>>> 5) Create virtual environment
>>>
>>> virtualenv -p python3 venv
>>>
>>> 6) Create mkdir Projects
>>>
>>> 7) Clone git repo in Projects
>>>
>>> git clone http://git.postgresql.org/git/pgadmin4.git
>>>
>>> 8) activate virtual environment
>>>
>>> source venv/bin/activate
>>>
>>> 9) Install modules
>>>
>>> pip3 install -r requirements_py3.txt
>>>
>>> *10) Edit the config.py file to config_local.py  resides in
>>> Projects\pgAdmin4\web *
>>>
>>> 11)Now run setup.py file  (\Projects\pgAdmin4\web)
>>> python setup.py
>>>
>>> If user does not create config_local.py and do Python setup.py for new
>>> Development then SECURITY_PASSWORD_SALT message is also displayed:
>>>
>>> Here is the output:
>>> -
>>>
>>> python setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>>
>>>
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>>
>>>
>>> Enter the email address and password to use for the initial pgAdmin
>>> user account:
>>>
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password:
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> 

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Sandeep Thakkar
Hi Dave,

On Wed, Oct 19, 2016 at 1:57 PM, Dave Page  wrote:

> Patch applied.
>
> Fahar, can you please test this thoroughly in desktop and server modes,
> with both fresh and upgraded installations?
>
> https://redmine.postgresql.org/issues/1849
>
> Packagers: This change means that packages are no longer forced to create
> a config_local.py file, and there is no longer any need to explicitly set
> SECURITY_PASSWORD_SALT, SECURITY_KEY and CSRF_SESSION_KEY in the config
> (in fact, they should be removed for new installations, if you have
> included them in 1.0)
>
> OK. Will remove config_local.py from the packaging. We do not set the
mentioned directives in the config.


> Thanks.
>
> On Wed, Oct 19, 2016 at 6:46 AM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Sat, Oct 15, 2016 at 8:02 AM, Dave Page  wrote:
>>
>>> Hi
>>>
>>>
>>> On Friday, October 14, 2016, Dave Page  wrote:
>>>
 Hi

 On Thursday, October 13, 2016, Ashesh Vashi <
 ashesh.va...@enterprisedb.com> wrote:

> Hi Dave,
>
> On Tue, Oct 11, 2016 at 9:10 PM, Dave Page  wrote:
>
>> Hi Ashesh,
>>
>> Can you please review the attached patch, and apply if you're happy
>> with it?
>>
> Overall the patch looked good to me.
> But - I encounter an issue in 'web' mode, which wont happen with
> 'runtime'.
>
> Steps for reproduction on existing pgAdmin 4 environment with 'web'
> mode.
> - Apply the patch
> - Start the pgAdmin4 application (stand alone application).
> - Open pgAdmin home page.
> - Log out (if already login).
>
> And, you will see an exception.
>
> I have figure out the issue with the patch.
> We were setting the SECURITY_PASSWORD_SALT, after initializing the
> Security object.
> Hence - it could not set the SECURITY_KEY, and SECURITY_PASSWORD_SALT
> properly.
>

 Hmm.


>
> I had moved the Security object initialization after fetching these
> configurations from the database.
> I have attached a addon patch for the same.
>

 OK, thanks.


>
> Now - I run into another issue.
> Because - the existing password was hashed using the old
> SECURITY_PASSWORD_SALT, I am no more able to login to pgAdmin 4.
>
> I think - we need to think about different strategy for upgrading the
> configuration file in the 'web' mode.
> I was thinking - we can store the existing security configurations in
> the database during upgrade process in 'web' mode.
>

 My concern with that is that we'll likely be storing the default config
 values in many cases, thus for those users, perpetuating the problem.

 I guess what we need to do is re-encrypt the password during the
 upgrade - however, that makes me think; we then have both the key and the
 encrypted passwords in the same database which is clearly not a good idea.
 Sigh... Needs more thought.

>>>
>>> OK, so I've been thinking about this and experimenting for a couple of
>>> hours, as well as annoying the crap out of Magnus by thinking out loud in
>>> his general direction, and it looks like this isn't a major problem as from
>>> what I can see,  SECURITY_PASSWORD_SALT is (aside from really being a key
>>> not a salt) not the only salting that's done.
>>>
>>> It looks like it's used system-wide as the key to generate an HMAC of
>>> the users password, which is then passed to passlib which salts and hashes
>>> it. I did some testing, and found that two users with the same password end
>>> up with different hashes in the database, so clearly there is also per-user
>>> salting happening. I also created two users, then dropped the database and
>>> created the same user accounts with the same passwords again, and found
>>> that the resulting hashes were different in both databases - thus there is
>>> something else ensuring the hashes are unique across different
>>> installations/databases.
>>>
>>> So, I believe we can do as you suggest and migrate existing values for
>>> SECURITY_PASSWORD_SALT, given that there's clearly some other per user and
>>> per installation/database salting going on anyway. New installations can
>>> have the random value for SECURITY_PASSWORD_SALT.
>>>
>> We do not need to generate the random SECURITY_PASSWORD_SALT during
>> upgrade mode, which was wrong added in my addon patch.
>>
>> Please find the updated patch.
>>
>> Otherwise - looks good to me.
>> Please commit the new patch (if you're ok with the change).
>>
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> 
>>
>>>
>>> I don't believe SECURITY_KEY and CSRF_SESSION_KEY are issues either, as
>>> they're used for purposes that are essentially ephemeral, and thus can be
>>> c

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Ashesh Vashi
Hi Fahar,

Please log the case on redmine.
Please find the attached patch, please apply it locally, and test it.

And, please update the case, and this mail chain accordingly.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



*http://www.linkedin.com/in/asheshvashi*


On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas 
wrote:

> Here is the output of if we copy config_local.py and execute python
> setup.py
> pgAdmin 4 - Application Initialisation
> ==
>
>
> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
> exist.
> Entering initial setup mode...
> NOTE: Configuring authentication for SERVER mode.
>
>
> Enter the email address and password to use for the initial pgAdmin
> user account:
>
> Email address: fahar.ab...@enterprisedb.com
> Password:
> Retype password:
> Traceback (most recent call last):
>   File "setup.py", line 449, in 
> do_setup(app)
>   File "setup.py", line 96, in do_setup
> password = encrypt_password(p1)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 150, in encrypt_password
> signed = get_hmac(password).decode('ascii')
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 108, in get_hmac
> 'set to "%s"' % _security.password_hash)
> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not be
> None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
> python setup.py
> pgAdmin 4 - Application Initialisation
> ==
>
> User can not do any setup for web based now.
>
>
> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
> exist.
> Entering initial setup mode...
> NOTE: Configuring authentication for SERVER mode.
>
>
> Enter the email address and password to use for the initial pgAdmin
> user account:
>
> Email address: fahar.ab...@enterprisedb.com
> Password:
> Retype password:
> Traceback (most recent call last):
>   File "setup.py", line 449, in 
> do_setup(app)
>   File "setup.py", line 96, in do_setup
> password = encrypt_password(p1)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 150, in encrypt_password
> signed = get_hmac(password).decode('ascii')
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 108, in get_hmac
> 'set to "%s"' % _security.password_hash)
> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not be
> None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>
> On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas  > wrote:
>
>> Dave,
>>
>> Testing Environment
>>
>> Ubuntu 16.04 Linux 64:
>> 
>>
>> pg-AdminIV Development Environment Setup for Ubuntu  :
>>
>>
>> 1) Install GIT
>>
>> sudo apt-get install git
>>
>> 2) Install pip3
>>
>> sudo apt-get install python3-pip
>>
>> 3) Install virtualenv
>>
>> sudo pip3 install virtualenv
>>
>> 4) install below dependency as it is required for psycopg2 & pycrypto
>> module
>>
>> sudo apt-get install libpq-dev
>>
>> sudo apt-get install python3-dev
>>
>> 5) Create virtual environment
>>
>> virtualenv -p python3 venv
>>
>> 6) Create mkdir Projects
>>
>> 7) Clone git repo in Projects
>>
>> git clone http://git.postgresql.org/git/pgadmin4.git
>>
>> 8) activate virtual environment
>>
>> source venv/bin/activate
>>
>> 9) Install modules
>>
>> pip3 install -r requirements_py3.txt
>>
>> *10) Edit the config.py file to config_local.py  resides in
>> Projects\pgAdmin4\web *
>>
>> 11)Now run setup.py file  (\Projects\pgAdmin4\web)
>> python setup.py
>>
>> If user does not create config_local.py and do Python setup.py for new
>> Development then SECURITY_PASSWORD_SALT message is also displayed:
>>
>> Here is the output:
>> -
>>
>> python setup.py
>> pgAdmin 4 - Application Initialisation
>> ==
>>
>>
>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
>> exist.
>> Entering initial setup mode...
>> NOTE: Configuring authentication for SERVER mode.
>>
>>
>> Enter the email address and password to use for the initial pgAdmin
>> user account:
>>
>> Email address: fahar.ab...@enterprisedb.com
>> Password:
>> Retype password:
>> Traceback (most recent call last):
>>   File "setup.py", line 449, in 
>> do_setup(app)
>>   File "setup.py", line 96, in do_setup
>> password = encrypt_password(p1)
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 150, in encrypt_password
>> signed = get_hmac(password).decode('ascii')
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 108, in get_hmac
>> 'set to "%s"' % _security.password_hash)
>> RuntimeError: The configur

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
On Wed, Oct 19, 2016 at 4:03 PM, Fahar Abbas 
wrote:

>
>
> On Wed, Oct 19, 2016 at 3:55 PM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Fahar,
>>
>> Please log the case on redmine.
>>
> https://redmine.postgresql.org/issues/1871
>
>> Please find the attached patch, please apply it locally, and test it.
>>
>> And, please update the case, and this mail chain accordingly.
>>
> This is resolved now and no error message displayed when we apply the
patch that is already shared.

>
>> Sure Will test the patch and update the status accordingly.
>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> 
>>
>> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas <
>> fahar.ab...@enterprisedb.com> wrote:
>>
>>> Here is the output of if we copy config_local.py and execute python
>>> setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>>
>>>
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>>
>>>
>>> Enter the email address and password to use for the initial pgAdmin
>>> user account:
>>>
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password:
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> password = encrypt_password(p1)
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 150, in encrypt_password
>>> signed = get_hmac(password).decode('ascii')
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 108, in get_hmac
>>> 'set to "%s"' % _security.password_hash)
>>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>>> python setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>>
>>> User can not do any setup for web based now.
>>>
>>>
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>>
>>>
>>> Enter the email address and password to use for the initial pgAdmin
>>> user account:
>>>
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password:
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> password = encrypt_password(p1)
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 150, in encrypt_password
>>> signed = get_hmac(password).decode('ascii')
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 108, in get_hmac
>>> 'set to "%s"' % _security.password_hash)
>>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>>>
>>> On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
>>> fahar.ab...@enterprisedb.com> wrote:
>>>
 Dave,

 Testing Environment

 Ubuntu 16.04 Linux 64:
 

 pg-AdminIV Development Environment Setup for Ubuntu  :


 1) Install GIT

 sudo apt-get install git

 2) Install pip3

 sudo apt-get install python3-pip

 3) Install virtualenv

 sudo pip3 install virtualenv

 4) install below dependency as it is required for psycopg2 & pycrypto
 module

 sudo apt-get install libpq-dev

 sudo apt-get install python3-dev

 5) Create virtual environment

 virtualenv -p python3 venv

 6) Create mkdir Projects

 7) Clone git repo in Projects

 git clone http://git.postgresql.org/git/pgadmin4.git

 8) activate virtual environment

 source venv/bin/activate

 9) Install modules

 pip3 install -r requirements_py3.txt

 *10) Edit the config.py file to config_local.py  resides in
 Projects\pgAdmin4\web *

 11)Now run setup.py file  (\Projects\pgAdmin4\web)
 python setup.py

 If user does not create config_local.py and do Python setup.py for new
 Development then SECURITY_PASSWORD_SALT message is also displayed:

 Here is the output:
 -

 python setup.py
 pgAdmin 4 - Application Initialisation
 ==


 The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
 not exist.
 Entering initial setup mode

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Dave Page
Great, thanks!

On Wed, Oct 19, 2016 at 12:42 PM, Fahar Abbas 
wrote:

>
>
> On Wed, Oct 19, 2016 at 4:03 PM, Fahar Abbas  > wrote:
>
>>
>>
>> On Wed, Oct 19, 2016 at 3:55 PM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Hi Fahar,
>>>
>>> Please log the case on redmine.
>>>
>> https://redmine.postgresql.org/issues/1871
>>
>>> Please find the attached patch, please apply it locally, and test it.
>>>
>>> And, please update the case, and this mail chain accordingly.
>>>
>> This is resolved now and no error message displayed when we apply the
> patch that is already shared.
>
>>
>>> Sure Will test the patch and update the status accordingly.
>>
>>> --
>>>
>>> Thanks & Regards,
>>>
>>> Ashesh Vashi
>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>> 
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> 
>>>
>>> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas <
>>> fahar.ab...@enterprisedb.com> wrote:
>>>
 Here is the output of if we copy config_local.py and execute python
 setup.py
 pgAdmin 4 - Application Initialisation
 ==


 The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
 not exist.
 Entering initial setup mode...
 NOTE: Configuring authentication for SERVER mode.


 Enter the email address and password to use for the initial pgAdmin
 user account:

 Email address: fahar.ab...@enterprisedb.com
 Password:
 Retype password:
 Traceback (most recent call last):
   File "setup.py", line 449, in 
 do_setup(app)
   File "setup.py", line 96, in do_setup
 password = encrypt_password(p1)
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 150, in encrypt_password
 signed = get_hmac(password).decode('ascii')
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 108, in get_hmac
 'set to "%s"' % _security.password_hash)
 RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
 be None when the value of `SECURITY_PASSWORD_HASH` is set to 
 "pbkdf2_sha512"
 python setup.py
 pgAdmin 4 - Application Initialisation
 ==

 User can not do any setup for web based now.


 The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
 not exist.
 Entering initial setup mode...
 NOTE: Configuring authentication for SERVER mode.


 Enter the email address and password to use for the initial pgAdmin
 user account:

 Email address: fahar.ab...@enterprisedb.com
 Password:
 Retype password:
 Traceback (most recent call last):
   File "setup.py", line 449, in 
 do_setup(app)
   File "setup.py", line 96, in do_setup
 password = encrypt_password(p1)
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 150, in encrypt_password
 signed = get_hmac(password).decode('ascii')
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 108, in get_hmac
 'set to "%s"' % _security.password_hash)
 RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
 be None when the value of `SECURITY_PASSWORD_HASH` is set to 
 "pbkdf2_sha512"

 On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
 fahar.ab...@enterprisedb.com> wrote:

> Dave,
>
> Testing Environment
>
> Ubuntu 16.04 Linux 64:
> 
>
> pg-AdminIV Development Environment Setup for Ubuntu  :
>
>
> 1) Install GIT
>
> sudo apt-get install git
>
> 2) Install pip3
>
> sudo apt-get install python3-pip
>
> 3) Install virtualenv
>
> sudo pip3 install virtualenv
>
> 4) install below dependency as it is required for psycopg2 & pycrypto
> module
>
> sudo apt-get install libpq-dev
>
> sudo apt-get install python3-dev
>
> 5) Create virtual environment
>
> virtualenv -p python3 venv
>
> 6) Create mkdir Projects
>
> 7) Clone git repo in Projects
>
> git clone http://git.postgresql.org/git/pgadmin4.git
>
> 8) activate virtual environment
>
> source venv/bin/activate
>
> 9) Install modules
>
> pip3 install -r requirements_py3.txt
>
> *10) Edit the config.py file to config_local.py  resides in
> Projects\pgAdmin4\web *
>
> 11)Now run setup.py file  (\Projects\pgAdmin4\web)
> python setup.py
>
> If user does not create config_local.py and do Python setup.py for new
> Development then SECURITY_PASSWORD_SALT message is also displayed:
>
> Here is the output:
> --

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Neel Patel
Hi,

Just to update for Python 3.
It gives below error while running "pgAdmin4.py".

#

Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/socketserver.py", line 620, in
process_request_thread
self.handle_error(request, client_address)
  File "/usr/lib/python3.4/socketserver.py", line 617, in
process_request_thread
self.finish_request(request, client_address)
  File "/usr/lib/python3.4/socketserver.py", line 344, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.4/socketserver.py", line 673, in __init__
self.handle()
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/werkzeug/serving.py",
line 200, in handle
rv = BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python3.4/http/server.py", line 398, in handle
self.handle_one_request()
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/werkzeug/serving.py",
line 235, in handle_one_request
return self.run_wsgi()
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/werkzeug/serving.py",
line 177, in run_wsgi
execute(self.server.app)
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/werkzeug/serving.py",
line 165, in execute
application_iter = app(environ, start_response)
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
line 2000, in __call__
return self.wsgi_app(environ, start_response)
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
line 1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
line 1567, in handle_exception
reraise(exc_type, exc_value, tb)
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/_compat.py",
line 33, in reraise
raise value
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
line 1988, in wsgi_app
response = self.full_dispatch_request()
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
line 1643, in full_dispatch_request
response = self.process_response(response)
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
line 1864, in process_response
self.save_session(ctx.session, response)
  File
"/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
line 926, in save_session
return self.session_interface.save_session(self, session, response)
  File
"/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
line 267, in save_session
self.manager.put(session)
  File
"/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
line 144, in put
self.parent.put(session)
  File
"/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
line 214, in put
session.sign(self.secret)
  File
"/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
line 71, in sign
self.hmac_digest = _calc_hmac('%s:%s' % (self.sid, self.randval),
secret)
  File
"/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
line 44, in _calc_hmac
secret.encode(), body.encode(), hashlib.sha1
AttributeError: 'bytes' object has no attribute 'encode'
 ###

Thanks,
Neel Patel

On Wed, Oct 19, 2016 at 5:12 PM, Fahar Abbas 
wrote:

>
>
> On Wed, Oct 19, 2016 at 4:03 PM, Fahar Abbas  > wrote:
>
>>
>>
>> On Wed, Oct 19, 2016 at 3:55 PM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Hi Fahar,
>>>
>>> Please log the case on redmine.
>>>
>> https://redmine.postgresql.org/issues/1871
>>
>>> Please find the attached patch, please apply it locally, and test it.
>>>
>>> And, please update the case, and this mail chain accordingly.
>>>
>> This is resolved now and no error message displayed when we apply the
> patch that is already shared.
>
>>
>>> Sure Will test the patch and update the status accordingly.
>>
>>> --
>>>
>>> Thanks & Regards,
>>>
>>> Ashesh Vashi
>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>> 
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> 
>>>
>>> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas <
>>> fahar.ab...@enterprisedb.com> wrote:
>>>
 Here is the output of if we copy config_local.py and execute python
 setup.py
 pgAdmin 4 - Application Initialisation
 ==


 The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
 not exist.
 Entering initial setup mode...
 NOTE: Configuring authentication for SERVER mode.

>>

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
Yes Neel is Right.

This issue is also reproducible with Python 3.5 when user Launch python
with pgAdmin4.py

python pgAdmin4.py
Starting pgAdmin 4. Please navigate to http://localhost:5050 in your
browser.
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.5/socketserver.py", line 628, in
process_request_thread
self.handle_error(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 625, in
process_request_thread
self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
self.handle()
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 200, in handle
rv = BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python3.5/http/server.py", line 422, in handle
self.handle_one_request()
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 235, in handle_one_request
return self.run_wsgi()
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 177, in run_wsgi
execute(self.server.app)
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 165, in execute
application_iter = app(environ, start_response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
2000, in __call__
return self.wsgi_app(environ, start_response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1567, in handle_exception
reraise(exc_type, exc_value, tb)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/_compat.py",
line 33, in reraise
raise value
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1988, in wsgi_app
response = self.full_dispatch_request()
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1643, in full_dispatch_request
response = self.process_response(response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1864, in process_response
self.save_session(ctx.session, response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
926, in save_session
return self.session_interface.save_session(self, session, response)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
267, in save_session
self.manager.put(session)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
144, in put
self.parent.put(session)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
214, in put
session.sign(self.secret)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
71, in sign
self.hmac_digest = _calc_hmac('%s:%s' % (self.sid, self.randval),
secret)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
44, in _calc_hmac
secret.encode(), body.encode(), hashlib.sha1
AttributeError: 'bytes' object has no attribute 'encode'


On Wed, Oct 19, 2016 at 5:11 PM, Neel Patel 
wrote:

> Hi,
>
> Just to update for Python 3.
> It gives below error while running "pgAdmin4.py".
>
> #
>
> Traceback (most recent call last):
>   File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
> self.run()
>   File "/usr/lib/python3.4/threading.py", line 868, in run
> self._target(*self._args, **self._kwargs)
>   File "/usr/lib/python3.4/socketserver.py", line 620, in
> process_request_thread
> self.handle_error(request, client_address)
>   File "/usr/lib/python3.4/socketserver.py", line 617, in
> process_request_thread
> self.finish_request(request, client_address)
>   File "/usr/lib/python3.4/socketserver.py", line 344, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File "/usr/lib/python3.4/socketserver.py", line 673, in __init__
> self.handle()
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 200, in handle
> rv = BaseHTTPRequestHandler.handle(self)
>   File "/usr/lib/python3.4/http/server.py", line 398, in handle
> self.handle_one_request()
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 235, in handle_one_request
> return self.run_wsgi()
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 177, in run_wsgi
> execute(self.server.app)
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 165,

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Sandeep Thakkar
Here is the patch where we remove the config_local.py being created during
packaging. The mac build script missed creating config_distro.py earlier
and it has been take care of now. Please review the attached patch.

I'll also make the changes in the EDB packaging scripts where we bundle
pgAdmin in PG server and EPAS Meta.

On Wed, Oct 19, 2016 at 4:35 PM, Sandeep Thakkar <
sandeep.thak...@enterprisedb.com> wrote:

> Hi Dave,
>
> On Wed, Oct 19, 2016 at 1:57 PM, Dave Page  wrote:
>
>> Patch applied.
>>
>> Fahar, can you please test this thoroughly in desktop and server modes,
>> with both fresh and upgraded installations?
>>
>> https://redmine.postgresql.org/issues/1849
>>
>> Packagers: This change means that packages are no longer forced to create
>> a config_local.py file, and there is no longer any need to explicitly set
>> SECURITY_PASSWORD_SALT, SECURITY_KEY and CSRF_SESSION_KEY in the config
>> (in fact, they should be removed for new installations, if you have
>> included them in 1.0)
>>
>> OK. Will remove config_local.py from the packaging. We do not set the
> mentioned directives in the config.
>
>
>> Thanks.
>>
>> On Wed, Oct 19, 2016 at 6:46 AM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> On Sat, Oct 15, 2016 at 8:02 AM, Dave Page  wrote:
>>>
 Hi


 On Friday, October 14, 2016, Dave Page  wrote:

> Hi
>
> On Thursday, October 13, 2016, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Tue, Oct 11, 2016 at 9:10 PM, Dave Page  wrote:
>>
>>> Hi Ashesh,
>>>
>>> Can you please review the attached patch, and apply if you're happy
>>> with it?
>>>
>> Overall the patch looked good to me.
>> But - I encounter an issue in 'web' mode, which wont happen with
>> 'runtime'.
>>
>> Steps for reproduction on existing pgAdmin 4 environment with 'web'
>> mode.
>> - Apply the patch
>> - Start the pgAdmin4 application (stand alone application).
>> - Open pgAdmin home page.
>> - Log out (if already login).
>>
>> And, you will see an exception.
>>
>> I have figure out the issue with the patch.
>> We were setting the SECURITY_PASSWORD_SALT, after initializing the
>> Security object.
>> Hence - it could not set the SECURITY_KEY, and SECURITY_PASSWORD_SALT
>> properly.
>>
>
> Hmm.
>
>
>>
>> I had moved the Security object initialization after fetching these
>> configurations from the database.
>> I have attached a addon patch for the same.
>>
>
> OK, thanks.
>
>
>>
>> Now - I run into another issue.
>> Because - the existing password was hashed using the old
>> SECURITY_PASSWORD_SALT, I am no more able to login to pgAdmin 4.
>>
>> I think - we need to think about different strategy for upgrading the
>> configuration file in the 'web' mode.
>> I was thinking - we can store the existing security configurations in
>> the database during upgrade process in 'web' mode.
>>
>
> My concern with that is that we'll likely be storing the default
> config values in many cases, thus for those users, perpetuating the 
> problem.
>
> I guess what we need to do is re-encrypt the password during the
> upgrade - however, that makes me think; we then have both the key and the
> encrypted passwords in the same database which is clearly not a good idea.
> Sigh... Needs more thought.
>

 OK, so I've been thinking about this and experimenting for a couple of
 hours, as well as annoying the crap out of Magnus by thinking out loud in
 his general direction, and it looks like this isn't a major problem as from
 what I can see,  SECURITY_PASSWORD_SALT is (aside from really being a key
 not a salt) not the only salting that's done.

 It looks like it's used system-wide as the key to generate an HMAC of
 the users password, which is then passed to passlib which salts and hashes
 it. I did some testing, and found that two users with the same password end
 up with different hashes in the database, so clearly there is also per-user
 salting happening. I also created two users, then dropped the database and
 created the same user accounts with the same passwords again, and found
 that the resulting hashes were different in both databases - thus there is
 something else ensuring the hashes are unique across different
 installations/databases.

 So, I believe we can do as you suggest and migrate existing values for
 SECURITY_PASSWORD_SALT, given that there's clearly some other per user and
 per installation/database salting going on anyway. New installations can
 have the random value for SECURITY_PASSWORD_SALT.

>>> We do not need to generate the random SECURITY_PASSWORD_SALT during
>>> upgrade mode, which was wrong added in m

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
After applying this patch on Python 2.7.11 on Windows 2012 64bit, User can
launch pgAdmin4 with python pgAdmin4.py without any error. Will also retest
once the 1871 will be resolved

On Wed, Oct 19, 2016 at 5:19 PM, Fahar Abbas 
wrote:

> Yes Neel is Right.
>
> This issue is also reproducible with Python 3.5 when user Launch python
> with pgAdmin4.py
>
> python pgAdmin4.py
> Starting pgAdmin 4. Please navigate to http://localhost:5050 in your
> browser.
> Exception in thread Thread-1:
> Traceback (most recent call last):
>   File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
> self.run()
>   File "/usr/lib/python3.5/threading.py", line 862, in run
> self._target(*self._args, **self._kwargs)
>   File "/usr/lib/python3.5/socketserver.py", line 628, in
> process_request_thread
> self.handle_error(request, client_address)
>   File "/usr/lib/python3.5/socketserver.py", line 625, in
> process_request_thread
> self.finish_request(request, client_address)
>   File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
> self.handle()
>   File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
> line 200, in handle
> rv = BaseHTTPRequestHandler.handle(self)
>   File "/usr/lib/python3.5/http/server.py", line 422, in handle
> self.handle_one_request()
>   File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
> line 235, in handle_one_request
> return self.run_wsgi()
>   File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
> line 177, in run_wsgi
> execute(self.server.app)
>   File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
> line 165, in execute
> application_iter = app(environ, start_response)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
> 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
> 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
> 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/_compat.py",
> line 33, in reraise
> raise value
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
> 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
> 1643, in full_dispatch_request
> response = self.process_response(response)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
> 1864, in process_response
> self.save_session(ctx.session, response)
>   File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
> 926, in save_session
> return self.session_interface.save_session(self, session, response)
>   File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
> 267, in save_session
> self.manager.put(session)
>   File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
> 144, in put
> self.parent.put(session)
>   File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
> 214, in put
> session.sign(self.secret)
>   File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
> 71, in sign
> self.hmac_digest = _calc_hmac('%s:%s' % (self.sid, self.randval),
> secret)
>   File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
> 44, in _calc_hmac
> secret.encode(), body.encode(), hashlib.sha1
> AttributeError: 'bytes' object has no attribute 'encode'
>
>
> On Wed, Oct 19, 2016 at 5:11 PM, Neel Patel 
> wrote:
>
>> Hi,
>>
>> Just to update for Python 3.
>> It gives below error while running "pgAdmin4.py".
>>
>> #
>>
>> Traceback (most recent call last):
>>   File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
>> self.run()
>>   File "/usr/lib/python3.4/threading.py", line 868, in run
>> self._target(*self._args, **self._kwargs)
>>   File "/usr/lib/python3.4/socketserver.py", line 620, in
>> process_request_thread
>> self.handle_error(request, client_address)
>>   File "/usr/lib/python3.4/socketserver.py", line 617, in
>> process_request_thread
>> self.finish_request(request, client_address)
>>   File "/usr/lib/python3.4/socketserver.py", line 344, in finish_request
>> self.RequestHandlerClass(request, client_address, self)
>>   File "/usr/lib/python3.4/socketserver.py", line 673, in __init__
>> self.handle()
>>   File 
>> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/werkzeug/serving.py",
>> line 200, in handle
>> rv = BaseHTTPRequestHandler.handle(self)
>>   File "/usr/lib/python3.4/http/server.py", line 398, in handle
>> self.handl

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Dave Page
I assume that's an existing issue with Python 3.5? That file wasn't changed
by this patch.

On Wed, Oct 19, 2016 at 1:11 PM, Neel Patel 
wrote:

> Hi,
>
> Just to update for Python 3.
> It gives below error while running "pgAdmin4.py".
>
> #
>
> Traceback (most recent call last):
>   File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
> self.run()
>   File "/usr/lib/python3.4/threading.py", line 868, in run
> self._target(*self._args, **self._kwargs)
>   File "/usr/lib/python3.4/socketserver.py", line 620, in
> process_request_thread
> self.handle_error(request, client_address)
>   File "/usr/lib/python3.4/socketserver.py", line 617, in
> process_request_thread
> self.finish_request(request, client_address)
>   File "/usr/lib/python3.4/socketserver.py", line 344, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File "/usr/lib/python3.4/socketserver.py", line 673, in __init__
> self.handle()
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 200, in handle
> rv = BaseHTTPRequestHandler.handle(self)
>   File "/usr/lib/python3.4/http/server.py", line 398, in handle
> self.handle_one_request()
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 235, in handle_one_request
> return self.run_wsgi()
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 177, in run_wsgi
> execute(self.server.app)
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/werkzeug/serving.py", line 165, in execute
> application_iter = app(environ, start_response)
>   File 
> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File 
> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File 
> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/
> site-packages/flask/_compat.py", line 33, in reraise
> raise value
>   File 
> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File 
> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
> line 1643, in full_dispatch_request
> response = self.process_response(response)
>   File 
> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
> line 1864, in process_response
> self.save_session(ctx.session, response)
>   File 
> "/home/neel/workspace/pgAdmin4_3_4/lib/python3.4/site-packages/flask/app.py",
> line 926, in save_session
> return self.session_interface.save_session(self, session, response)
>   File 
> "/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
> line 267, in save_session
> self.manager.put(session)
>   File 
> "/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
> line 144, in put
> self.parent.put(session)
>   File 
> "/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
> line 214, in put
> session.sign(self.secret)
>   File 
> "/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
> line 71, in sign
> self.hmac_digest = _calc_hmac('%s:%s' % (self.sid, self.randval),
> secret)
>   File 
> "/home/neel/Projects/pgAdmin4/pgadmin4_patch/pgadmin4/web/pgadmin/utils/session.py",
> line 44, in _calc_hmac
> secret.encode(), body.encode(), hashlib.sha1
> AttributeError: 'bytes' object has no attribute 'encode'
>  ###
>
> Thanks,
> Neel Patel
>
> On Wed, Oct 19, 2016 at 5:12 PM, Fahar Abbas  > wrote:
>
>>
>>
>> On Wed, Oct 19, 2016 at 4:03 PM, Fahar Abbas <
>> fahar.ab...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Wed, Oct 19, 2016 at 3:55 PM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
 Hi Fahar,

 Please log the case on redmine.

>>> https://redmine.postgresql.org/issues/1871
>>>
 Please find the attached patch, please apply it locally, and test it.

 And, please update the case, and this mail chain accordingly.

>>> This is resolved now and no error message displayed when we apply the
>> patch that is already shared.
>>
>>>
 Sure Will test the patch and update the status accordingly.
>>>
 --

 Thanks & Regards,

 Ashesh Vashi
 EnterpriseDB INDIA: Enterprise PostgreSQL Company
 


 *http://www.linkedin.com/in/asheshvashi*
 

 On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas 

[pgadmin-hackers] pgAdmin 4 commit: Ensure SECURITY_PASSWORD_SALT is set to something whe

2016-10-19 Thread Dave Page
Ensure SECURITY_PASSWORD_SALT is set to something when initialising (to avoid 
errors, prior to being set to the 'real' value). Fixes #1871

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=19df1e3f4b27523f8f401a78ca8747dbfbb5fcfe
Author: Ashesh Vashi 

Modified Files
--
web/setup.py | 2 ++
1 file changed, 2 insertions(+)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Dave Page
Patch applied.

On Wed, Oct 19, 2016 at 11:55 AM, Ashesh Vashi <
ashesh.va...@enterprisedb.com> wrote:

> Hi Fahar,
>
> Please log the case on redmine.
> Please find the attached patch, please apply it locally, and test it.
>
> And, please update the case, and this mail chain accordingly.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas  > wrote:
>
>> Here is the output of if we copy config_local.py and execute python
>> setup.py
>> pgAdmin 4 - Application Initialisation
>> ==
>>
>>
>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
>> exist.
>> Entering initial setup mode...
>> NOTE: Configuring authentication for SERVER mode.
>>
>>
>> Enter the email address and password to use for the initial pgAdmin
>> user account:
>>
>> Email address: fahar.ab...@enterprisedb.com
>> Password:
>> Retype password:
>> Traceback (most recent call last):
>>   File "setup.py", line 449, in 
>> do_setup(app)
>>   File "setup.py", line 96, in do_setup
>> password = encrypt_password(p1)
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 150, in encrypt_password
>> signed = get_hmac(password).decode('ascii')
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 108, in get_hmac
>> 'set to "%s"' % _security.password_hash)
>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>> python setup.py
>> pgAdmin 4 - Application Initialisation
>> ==
>>
>> User can not do any setup for web based now.
>>
>>
>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does not
>> exist.
>> Entering initial setup mode...
>> NOTE: Configuring authentication for SERVER mode.
>>
>>
>> Enter the email address and password to use for the initial pgAdmin
>> user account:
>>
>> Email address: fahar.ab...@enterprisedb.com
>> Password:
>> Retype password:
>> Traceback (most recent call last):
>>   File "setup.py", line 449, in 
>> do_setup(app)
>>   File "setup.py", line 96, in do_setup
>> password = encrypt_password(p1)
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 150, in encrypt_password
>> signed = get_hmac(password).decode('ascii')
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 108, in get_hmac
>> 'set to "%s"' % _security.password_hash)
>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>>
>> On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
>> fahar.ab...@enterprisedb.com> wrote:
>>
>>> Dave,
>>>
>>> Testing Environment
>>>
>>> Ubuntu 16.04 Linux 64:
>>> 
>>>
>>> pg-AdminIV Development Environment Setup for Ubuntu  :
>>>
>>>
>>> 1) Install GIT
>>>
>>> sudo apt-get install git
>>>
>>> 2) Install pip3
>>>
>>> sudo apt-get install python3-pip
>>>
>>> 3) Install virtualenv
>>>
>>> sudo pip3 install virtualenv
>>>
>>> 4) install below dependency as it is required for psycopg2 & pycrypto
>>> module
>>>
>>> sudo apt-get install libpq-dev
>>>
>>> sudo apt-get install python3-dev
>>>
>>> 5) Create virtual environment
>>>
>>> virtualenv -p python3 venv
>>>
>>> 6) Create mkdir Projects
>>>
>>> 7) Clone git repo in Projects
>>>
>>> git clone http://git.postgresql.org/git/pgadmin4.git
>>>
>>> 8) activate virtual environment
>>>
>>> source venv/bin/activate
>>>
>>> 9) Install modules
>>>
>>> pip3 install -r requirements_py3.txt
>>>
>>> *10) Edit the config.py file to config_local.py  resides in
>>> Projects\pgAdmin4\web *
>>>
>>> 11)Now run setup.py file  (\Projects\pgAdmin4\web)
>>> python setup.py
>>>
>>> If user does not create config_local.py and do Python setup.py for new
>>> Development then SECURITY_PASSWORD_SALT message is also displayed:
>>>
>>> Here is the output:
>>> -
>>>
>>> python setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>>
>>>
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>>
>>>
>>> Enter the email address and password to use for the initial pgAdmin
>>> user account:
>>>
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password:
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> password = encrypt_password(p1)
>>>   File 
>>> "/home/f

[pgadmin-hackers] pgAdmin 4 commit: Use config_distro.py for all settings, and don't crea

2016-10-19 Thread Dave Page
Use config_distro.py for all settings, and don't create/overwrite 
config_local.py. Partly fixes #1849

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=a1c0042a1e95d5329bceb3650219e804f080de10
Author: Sandeep Thakkar 

Modified Files
--
Make.bat | 3 ---
pkg/mac/build.sh | 6 +++---
2 files changed, 3 insertions(+), 6 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Dave Page
Thanks, applied.

On Wed, Oct 19, 2016 at 1:39 PM, Sandeep Thakkar <
sandeep.thak...@enterprisedb.com> wrote:

> Here is the patch where we remove the config_local.py being created during
> packaging. The mac build script missed creating config_distro.py earlier
> and it has been take care of now. Please review the attached patch.
>
> I'll also make the changes in the EDB packaging scripts where we bundle
> pgAdmin in PG server and EPAS Meta.
>
> On Wed, Oct 19, 2016 at 4:35 PM, Sandeep Thakkar <
> sandeep.thak...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Wed, Oct 19, 2016 at 1:57 PM, Dave Page  wrote:
>>
>>> Patch applied.
>>>
>>> Fahar, can you please test this thoroughly in desktop and server modes,
>>> with both fresh and upgraded installations?
>>>
>>> https://redmine.postgresql.org/issues/1849
>>>
>>> Packagers: This change means that packages are no longer forced to
>>> create a config_local.py file, and there is no longer any need to
>>> explicitly set SECURITY_PASSWORD_SALT, SECURITY_KEY
>>> and CSRF_SESSION_KEY in the config (in fact, they should be removed for new
>>> installations, if you have included them in 1.0)
>>>
>>> OK. Will remove config_local.py from the packaging. We do not set the
>> mentioned directives in the config.
>>
>>
>>> Thanks.
>>>
>>> On Wed, Oct 19, 2016 at 6:46 AM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
 Hi Dave,

 On Sat, Oct 15, 2016 at 8:02 AM, Dave Page  wrote:

> Hi
>
>
> On Friday, October 14, 2016, Dave Page  wrote:
>
>> Hi
>>
>> On Thursday, October 13, 2016, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> On Tue, Oct 11, 2016 at 9:10 PM, Dave Page 
>>> wrote:
>>>
 Hi Ashesh,

 Can you please review the attached patch, and apply if you're happy
 with it?

>>> Overall the patch looked good to me.
>>> But - I encounter an issue in 'web' mode, which wont happen with
>>> 'runtime'.
>>>
>>> Steps for reproduction on existing pgAdmin 4 environment with 'web'
>>> mode.
>>> - Apply the patch
>>> - Start the pgAdmin4 application (stand alone application).
>>> - Open pgAdmin home page.
>>> - Log out (if already login).
>>>
>>> And, you will see an exception.
>>>
>>> I have figure out the issue with the patch.
>>> We were setting the SECURITY_PASSWORD_SALT, after initializing the
>>> Security object.
>>> Hence - it could not set the SECURITY_KEY, and
>>> SECURITY_PASSWORD_SALT properly.
>>>
>>
>> Hmm.
>>
>>
>>>
>>> I had moved the Security object initialization after fetching these
>>> configurations from the database.
>>> I have attached a addon patch for the same.
>>>
>>
>> OK, thanks.
>>
>>
>>>
>>> Now - I run into another issue.
>>> Because - the existing password was hashed using the old
>>> SECURITY_PASSWORD_SALT, I am no more able to login to pgAdmin 4.
>>>
>>> I think - we need to think about different strategy for upgrading
>>> the configuration file in the 'web' mode.
>>> I was thinking - we can store the existing security configurations
>>> in the database during upgrade process in 'web' mode.
>>>
>>
>> My concern with that is that we'll likely be storing the default
>> config values in many cases, thus for those users, perpetuating the 
>> problem.
>>
>> I guess what we need to do is re-encrypt the password during the
>> upgrade - however, that makes me think; we then have both the key and the
>> encrypted passwords in the same database which is clearly not a good 
>> idea.
>> Sigh... Needs more thought.
>>
>
> OK, so I've been thinking about this and experimenting for a couple of
> hours, as well as annoying the crap out of Magnus by thinking out loud in
> his general direction, and it looks like this isn't a major problem as 
> from
> what I can see,  SECURITY_PASSWORD_SALT is (aside from really being a key
> not a salt) not the only salting that's done.
>
> It looks like it's used system-wide as the key to generate an HMAC of
> the users password, which is then passed to passlib which salts and hashes
> it. I did some testing, and found that two users with the same password 
> end
> up with different hashes in the database, so clearly there is also 
> per-user
> salting happening. I also created two users, then dropped the database and
> created the same user accounts with the same passwords again, and found
> that the resulting hashes were different in both databases - thus there is
> something else ensuring the hashes are unique across different
> installations/databases.
>
> So, I believe we can do as you suggest and migrate existing values for
> SECURITY_PASSWORD_SALT, given that there's c

Re: [pgadmin-hackers] Setting up pgAdmin4 as a web application

2016-10-19 Thread Dave Page
[Please keep the mailing list CC'd]

On Wed, Oct 19, 2016 at 3:32 PM, Derek Ealy  wrote:
> I had already tried something similar and it didn't work.
>
> I moved my stuff out of /var/www/.pgadmin to the directory locations you
> suggested and set ownership to the www-data user and group. After restarting
> apache I get exactly the same error message as before. The pgadmin4.db file
> is created in /var/lib/pgadmin4 and is set to: -rw-r--r--  1 www-data
> www-data0 Oct 19 07:25 pgadmin4.db. However the file remains at zero
> bytes. So there are enough permissions to create all of the files in the
> specified directories. But something is still preventing the actual writing
> to the DB file.
>
> Is there some way that the pgadmin python logic could be running as a
> different user than the apache http process?

Nothing in our code.

You could try the following:

1) Delete pgadmin4.db
2) Run setup.py as root
3) If that appears successful, "chown www-data:www-data pgadmin4.db"
4) See if it works

If not, please send a copy of your config files, and any logs or
screen output that may be relevant.

Thanks.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Setting up pgAdmin4 as a web application

2016-10-19 Thread dealy663
Ok, I'll give that a try.

I have my python setup to use a virtual environment. Could that be causing
the problems I'm having? I was able to get the venv setup with pgAdmin4
working on my workstation and thought that was the right way to set things
up on the server.



--
View this message in context: 
http://postgresql.nabble.com/Setting-up-pgAdmin4-as-a-web-application-tp5926369p5926569.html
Sent from the PostgreSQL - pgadmin hackers mailing list archive at Nabble.com.


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Setting up pgAdmin4 as a web application

2016-10-19 Thread Dave Page
On Wed, Oct 19, 2016 at 3:43 PM, dealy663  wrote:
> Ok, I'll give that a try.
>
> I have my python setup to use a virtual environment. Could that be causing
> the problems I'm having? I was able to get the venv setup with pgAdmin4
> working on my workstation and thought that was the right way to set things
> up on the server.

I haven't tried it in a venv on a server (though my dev environment is
setup that way). It should work, but you may need to adjust the wsgi
file or Apache config to point to the virtual env.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Setting up pgAdmin4 as a web application

2016-10-19 Thread Murtuza Zabuawala
You can refer my config for activating virtual environment.
http://i.stack.imgur.com/8HbKw.png


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Oct 19, 2016 at 8:19 PM, Dave Page  wrote:

> On Wed, Oct 19, 2016 at 3:43 PM, dealy663  wrote:
> > Ok, I'll give that a try.
> >
> > I have my python setup to use a virtual environment. Could that be
> causing
> > the problems I'm having? I was able to get the venv setup with pgAdmin4
> > working on my workstation and thought that was the right way to set
> things
> > up on the server.
>
> I haven't tried it in a venv on a server (though my dev environment is
> setup that way). It should work, but you may need to adjust the wsgi
> file or Apache config to point to the virtual env.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>


Re: [pgadmin-hackers] Setting up pgAdmin4 as a web application

2016-10-19 Thread Dave Page
On Wed, Oct 19, 2016 at 4:01 PM, Murtuza Zabuawala
 wrote:
> You can refer my config for activating virtual environment.
> http://i.stack.imgur.com/8HbKw.png

That's your replacement wsgi file?

I wonder if we should source a user-editable file from our standard
WSGI file to allow the user to easily specify a virtual env to
activate. Thoughts?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
Hi Dave,

I have reopened following RM:

https://redmine.postgresql.org/issues/1849

On Wed, Oct 19, 2016 at 6:04 PM, Dave Page  wrote:

> Patch applied.
>
> On Wed, Oct 19, 2016 at 11:55 AM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Fahar,
>>
>> Please log the case on redmine.
>> Please find the attached patch, please apply it locally, and test it.
>>
>> And, please update the case, and this mail chain accordingly.
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> 
>>
>> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas <
>> fahar.ab...@enterprisedb.com> wrote:
>>
>>> Here is the output of if we copy config_local.py and execute python
>>> setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>>
>>>
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>>
>>>
>>> Enter the email address and password to use for the initial pgAdmin
>>> user account:
>>>
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password:
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> password = encrypt_password(p1)
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 150, in encrypt_password
>>> signed = get_hmac(password).decode('ascii')
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 108, in get_hmac
>>> 'set to "%s"' % _security.password_hash)
>>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>>> python setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>>
>>> User can not do any setup for web based now.
>>>
>>>
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>>
>>>
>>> Enter the email address and password to use for the initial pgAdmin
>>> user account:
>>>
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password:
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> password = encrypt_password(p1)
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 150, in encrypt_password
>>> signed = get_hmac(password).decode('ascii')
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>>> line 108, in get_hmac
>>> 'set to "%s"' % _security.password_hash)
>>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
>>> be None when the value of `SECURITY_PASSWORD_HASH` is set to "pbkdf2_sha512"
>>>
>>> On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
>>> fahar.ab...@enterprisedb.com> wrote:
>>>
 Dave,

 Testing Environment

 Ubuntu 16.04 Linux 64:
 

 pg-AdminIV Development Environment Setup for Ubuntu  :


 1) Install GIT

 sudo apt-get install git

 2) Install pip3

 sudo apt-get install python3-pip

 3) Install virtualenv

 sudo pip3 install virtualenv

 4) install below dependency as it is required for psycopg2 & pycrypto
 module

 sudo apt-get install libpq-dev

 sudo apt-get install python3-dev

 5) Create virtual environment

 virtualenv -p python3 venv

 6) Create mkdir Projects

 7) Clone git repo in Projects

 git clone http://git.postgresql.org/git/pgadmin4.git

 8) activate virtual environment

 source venv/bin/activate

 9) Install modules

 pip3 install -r requirements_py3.txt

 *10) Edit the config.py file to config_local.py  resides in
 Projects\pgAdmin4\web *

 11)Now run setup.py file  (\Projects\pgAdmin4\web)
 python setup.py

 If user does not create config_local.py and do Python setup.py for new
 Development then SECURITY_PASSWORD_SALT message is also displayed:

 Here is the output:
 -

 python setup.py
 pgAdmin 4 - Application Initialisation
 ==


 The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
 not exist.
 Entering initial setup mode...
 NOTE: Configuring authentication for SERVER mode.


 Enter the e

[pgadmin-hackers] [pgAdmin4][Patch]: RM1599 - Unable to fetch the records for grant wizard if schema contains special characters

2016-10-19 Thread Surinder Kumar
Hi,

Issue:
The schema name was passed into the template files to get schema name in
response which doesn't escape special characters.

Now schema is fetched using a JOIN statement on needed tables.

Please find attached patch and review.

Thanks,
Surinder Kumar


RM1599.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue for Pyhton3.
RM#1849

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Oct 20, 2016 at 11:03 AM, Fahar Abbas 
wrote:

> Hi Dave,
>
> I have reopened following RM:
> 
> https://redmine.postgresql.org/issues/1849
>
> On Wed, Oct 19, 2016 at 6:04 PM, Dave Page  wrote:
>
>> Patch applied.
>>
>> On Wed, Oct 19, 2016 at 11:55 AM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Hi Fahar,
>>>
>>> Please log the case on redmine.
>>> Please find the attached patch, please apply it locally, and test it.
>>>
>>> And, please update the case, and this mail chain accordingly.
>>>
>>> --
>>>
>>> Thanks & Regards,
>>>
>>> Ashesh Vashi
>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>> 
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> 
>>>
>>> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas <
>>> fahar.ab...@enterprisedb.com> wrote:
>>>
 Here is the output of if we copy config_local.py and execute python
 setup.py
 pgAdmin 4 - Application Initialisation
 ==


 The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
 not exist.
 Entering initial setup mode...
 NOTE: Configuring authentication for SERVER mode.


 Enter the email address and password to use for the initial pgAdmin
 user account:

 Email address: fahar.ab...@enterprisedb.com
 Password:
 Retype password:
 Traceback (most recent call last):
   File "setup.py", line 449, in 
 do_setup(app)
   File "setup.py", line 96, in do_setup
 password = encrypt_password(p1)
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 150, in encrypt_password
 signed = get_hmac(password).decode('ascii')
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 108, in get_hmac
 'set to "%s"' % _security.password_hash)
 RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
 be None when the value of `SECURITY_PASSWORD_HASH` is set to 
 "pbkdf2_sha512"
 python setup.py
 pgAdmin 4 - Application Initialisation
 ==

 User can not do any setup for web based now.


 The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
 not exist.
 Entering initial setup mode...
 NOTE: Configuring authentication for SERVER mode.


 Enter the email address and password to use for the initial pgAdmin
 user account:

 Email address: fahar.ab...@enterprisedb.com
 Password:
 Retype password:
 Traceback (most recent call last):
   File "setup.py", line 449, in 
 do_setup(app)
   File "setup.py", line 96, in do_setup
 password = encrypt_password(p1)
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 150, in encrypt_password
 signed = get_hmac(password).decode('ascii')
   File 
 "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
 line 108, in get_hmac
 'set to "%s"' % _security.password_hash)
 RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not
 be None when the value of `SECURITY_PASSWORD_HASH` is set to 
 "pbkdf2_sha512"

 On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
 fahar.ab...@enterprisedb.com> wrote:

> Dave,
>
> Testing Environment
>
> Ubuntu 16.04 Linux 64:
> 
>
> pg-AdminIV Development Environment Setup for Ubuntu  :
>
>
> 1) Install GIT
>
> sudo apt-get install git
>
> 2) Install pip3
>
> sudo apt-get install python3-pip
>
> 3) Install virtualenv
>
> sudo pip3 install virtualenv
>
> 4) install below dependency as it is required for psycopg2 & pycrypto
> module
>
> sudo apt-get install libpq-dev
>
> sudo apt-get install python3-dev
>
> 5) Create virtual environment
>
> virtualenv -p python3 venv
>
> 6) Create mkdir Projects
>
> 7) Clone git repo in Projects
>
> git clone http://git.postgresql.org/git/pgadmin4.git
>
> 8) activate virtual environment
>
> source venv/bin/activate
>
> 9) Install modules
>
> pip3 install -r requirements_py3.txt
>
> *10) Edit the config.py file to config_local.py  resides in
> Projects\pgAdmin4\web *
>
> 11)Now run setup.py file  (\Projects\pgAdmin4\web)
> python setup.py
>
> If user does not create config_local.py and do Python setup.py for new
> Development then SECURITY_PASSWORD_SALT message is also displayed:
>>

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
Murtaza,

I have applied this patch and there is no success on new pgAdmin4 setup as
well as existing pgAdmin4 setup.

On Thu, Oct 20, 2016 at 10:45 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix the issue for Pyhton3.
> RM#1849
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Oct 20, 2016 at 11:03 AM, Fahar Abbas <
> fahar.ab...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> I have reopened following RM:
>> 
>> https://redmine.postgresql.org/issues/1849
>>
>> On Wed, Oct 19, 2016 at 6:04 PM, Dave Page  wrote:
>>
>>> Patch applied.
>>>
>>> On Wed, Oct 19, 2016 at 11:55 AM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
 Hi Fahar,

 Please log the case on redmine.
 Please find the attached patch, please apply it locally, and test it.

 And, please update the case, and this mail chain accordingly.

 --

 Thanks & Regards,

 Ashesh Vashi
 EnterpriseDB INDIA: Enterprise PostgreSQL Company
 


 *http://www.linkedin.com/in/asheshvashi*
 

 On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas <
 fahar.ab...@enterprisedb.com> wrote:

> Here is the output of if we copy config_local.py and execute python
> setup.py
> pgAdmin 4 - Application Initialisation
> ==
>
>
> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
> not exist.
> Entering initial setup mode...
> NOTE: Configuring authentication for SERVER mode.
>
>
> Enter the email address and password to use for the initial
> pgAdmin user account:
>
> Email address: fahar.ab...@enterprisedb.com
> Password:
> Retype password:
> Traceback (most recent call last):
>   File "setup.py", line 449, in 
> do_setup(app)
>   File "setup.py", line 96, in do_setup
> password = encrypt_password(p1)
>   File 
> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 150, in encrypt_password
> signed = get_hmac(password).decode('ascii')
>   File 
> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 108, in get_hmac
> 'set to "%s"' % _security.password_hash)
> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must
> not be None when the value of `SECURITY_PASSWORD_HASH` is set to
> "pbkdf2_sha512"
> python setup.py
> pgAdmin 4 - Application Initialisation
> ==
>
> User can not do any setup for web based now.
>
>
> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
> not exist.
> Entering initial setup mode...
> NOTE: Configuring authentication for SERVER mode.
>
>
> Enter the email address and password to use for the initial
> pgAdmin user account:
>
> Email address: fahar.ab...@enterprisedb.com
> Password:
> Retype password:
> Traceback (most recent call last):
>   File "setup.py", line 449, in 
> do_setup(app)
>   File "setup.py", line 96, in do_setup
> password = encrypt_password(p1)
>   File 
> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 150, in encrypt_password
> signed = get_hmac(password).decode('ascii')
>   File 
> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
> line 108, in get_hmac
> 'set to "%s"' % _security.password_hash)
> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must
> not be None when the value of `SECURITY_PASSWORD_HASH` is set to
> "pbkdf2_sha512"
>
> On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
> fahar.ab...@enterprisedb.com> wrote:
>
>> Dave,
>>
>> Testing Environment
>>
>> Ubuntu 16.04 Linux 64:
>> 
>>
>> pg-AdminIV Development Environment Setup for Ubuntu  :
>>
>>
>> 1) Install GIT
>>
>> sudo apt-get install git
>>
>> 2) Install pip3
>>
>> sudo apt-get install python3-pip
>>
>> 3) Install virtualenv
>>
>> sudo pip3 install virtualenv
>>
>> 4) install below dependency as it is required for psycopg2 & pycrypto
>> module
>>
>> sudo apt-get install libpq-dev
>>
>> sudo apt-get install python3-dev
>>
>> 5) Create virtual environment
>>
>> virtualenv -p python3 venv
>>
>> 6) Create mkdir Projects
>>
>> 7) Clone git repo in Projects
>>
>> git clone http://git.postgresql.org/git/pgadmin4.git
>>
>> 8) activate virtual environment
>>
>> source venv/bin/activate
>>
>>

Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Murtuza Zabuawala
Could you delete 'keys' table from pgadmin4.db file & try again?

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Oct 20, 2016 at 11:26 AM, Fahar Abbas 
wrote:

> Murtaza,
>
> I have applied this patch and there is no success on new pgAdmin4 setup as
> well as existing pgAdmin4 setup.
>
> On Thu, Oct 20, 2016 at 10:45 AM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix the issue for Pyhton3.
>> RM#1849
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Thu, Oct 20, 2016 at 11:03 AM, Fahar Abbas <
>> fahar.ab...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> I have reopened following RM:
>>> 
>>> https://redmine.postgresql.org/issues/1849
>>>
>>> On Wed, Oct 19, 2016 at 6:04 PM, Dave Page  wrote:
>>>
 Patch applied.

 On Wed, Oct 19, 2016 at 11:55 AM, Ashesh Vashi <
 ashesh.va...@enterprisedb.com> wrote:

> Hi Fahar,
>
> Please log the case on redmine.
> Please find the attached patch, please apply it locally, and test it.
>
> And, please update the case, and this mail chain accordingly.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas <
> fahar.ab...@enterprisedb.com> wrote:
>
>> Here is the output of if we copy config_local.py and execute python
>> setup.py
>> pgAdmin 4 - Application Initialisation
>> ==
>>
>>
>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>> not exist.
>> Entering initial setup mode...
>> NOTE: Configuring authentication for SERVER mode.
>>
>>
>> Enter the email address and password to use for the initial
>> pgAdmin user account:
>>
>> Email address: fahar.ab...@enterprisedb.com
>> Password:
>> Retype password:
>> Traceback (most recent call last):
>>   File "setup.py", line 449, in 
>> do_setup(app)
>>   File "setup.py", line 96, in do_setup
>> password = encrypt_password(p1)
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 150, in encrypt_password
>> signed = get_hmac(password).decode('ascii')
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 108, in get_hmac
>> 'set to "%s"' % _security.password_hash)
>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must
>> not be None when the value of `SECURITY_PASSWORD_HASH` is set to
>> "pbkdf2_sha512"
>> python setup.py
>> pgAdmin 4 - Application Initialisation
>> ==
>>
>> User can not do any setup for web based now.
>>
>>
>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does
>> not exist.
>> Entering initial setup mode...
>> NOTE: Configuring authentication for SERVER mode.
>>
>>
>> Enter the email address and password to use for the initial
>> pgAdmin user account:
>>
>> Email address: fahar.ab...@enterprisedb.com
>> Password:
>> Retype password:
>> Traceback (most recent call last):
>>   File "setup.py", line 449, in 
>> do_setup(app)
>>   File "setup.py", line 96, in do_setup
>> password = encrypt_password(p1)
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 150, in encrypt_password
>> signed = get_hmac(password).decode('ascii')
>>   File 
>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py",
>> line 108, in get_hmac
>> 'set to "%s"' % _security.password_hash)
>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must
>> not be None when the value of `SECURITY_PASSWORD_HASH` is set to
>> "pbkdf2_sha512"
>>
>> On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas <
>> fahar.ab...@enterprisedb.com> wrote:
>>
>>> Dave,
>>>
>>> Testing Environment
>>>
>>> Ubuntu 16.04 Linux 64:
>>> 
>>>
>>> pg-AdminIV Development Environment Setup for Ubuntu  :
>>>
>>>
>>> 1) Install GIT
>>>
>>> sudo apt-get install git
>>>
>>> 2) Install pip3
>>>
>>> sudo apt-get install python3-pip
>>>
>>> 3) Install virtualenv
>>>
>>> sudo pip3 install virtualenv
>>>
>>> 4) install below dependency as it is required for psycopg2 &
>>> pycrypto module
>>>
>>> sudo apt-get install libpq-dev
>>>

[pgadmin-hackers] patch for RM1861 [pgAdmin4]

2016-10-19 Thread Harshal Dhumal
Hi,

PFA minor patch for RM1861.

Issue fixed: SQL not generated for exclusion constraint on table

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
index 3298a51..6bc0bb0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -804,7 +804,7 @@ class ExclusionConstraintView(PGChildNodeView):
 sql = render_template("/".join([self.template_path, 'create.sql']),
   data=data, conn=self.conn)
 
-return sql
+return sql, data['name'] if 'name' in data else old_data['name']
 
 @check_precondition
 def sql(self, gid, sid, did, scid, tid, exid=None):

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Fahar Abbas
I tried different variations and when launch pgAdmin4 with web browser
still exception displayed when user deleted .pgadmin folder

Here is the output:

python pgAdmin4.py
Starting pgAdmin 4. Please navigate to http://localhost:5050 in your
browser.
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.5/socketserver.py", line 628, in
process_request_thread
self.handle_error(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 625, in
process_request_thread
self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
self.handle()
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 200, in handle
rv = BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python3.5/http/server.py", line 415, in handle
self.handle_one_request()
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 235, in handle_one_request
return self.run_wsgi()
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 177, in run_wsgi
execute(self.server.app)
  File "/home/fahar/venv/lib/python3.5/site-packages/werkzeug/serving.py",
line 165, in execute
application_iter = app(environ, start_response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
2000, in __call__
return self.wsgi_app(environ, start_response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1567, in handle_exception
reraise(exc_type, exc_value, tb)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/_compat.py",
line 33, in reraise
raise value
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1988, in wsgi_app
response = self.full_dispatch_request()
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1643, in full_dispatch_request
response = self.process_response(response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
1864, in process_response
self.save_session(ctx.session, response)
  File "/home/fahar/venv/lib/python3.5/site-packages/flask/app.py", line
926, in save_session
return self.session_interface.save_session(self, session, response)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
267, in save_session
self.manager.put(session)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
144, in put
self.parent.put(session)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
214, in put
session.sign(self.secret)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
71, in sign
self.hmac_digest = _calc_hmac('%s:%s' % (self.sid, self.randval),
secret)
  File "/home/fahar/Projects/pgadmin4/web/pgadmin/utils/session.py", line
44, in _calc_hmac
secret.encode(), body.encode(), hashlib.sha1
AttributeError: 'bytes' object has no attribute 'encode'


On Thu, Oct 20, 2016 at 11:00 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Could you delete 'keys' table from pgadmin4.db file & try again?
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Oct 20, 2016 at 11:26 AM, Fahar Abbas <
> fahar.ab...@enterprisedb.com> wrote:
>
>> Murtaza,
>>
>> I have applied this patch and there is no success on new pgAdmin4 setup
>> as well as existing pgAdmin4 setup.
>>
>> On Thu, Oct 20, 2016 at 10:45 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to fix the issue for Pyhton3.
>>> RM#1849
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Thu, Oct 20, 2016 at 11:03 AM, Fahar Abbas <
>>> fahar.ab...@enterprisedb.com> wrote:
>>>
 Hi Dave,

 I have reopened following RM:
 
 https://redmine.postgresql.org/issues/1849

 On Wed, Oct 19, 2016 at 6:04 PM, Dave Page  wrote:

> Patch applied.
>
> On Wed, Oct 19, 2016 at 11:55 AM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Fahar,
>>
>> Please log the case on redmine.
>> Please find the attached patch, please apply it locally, and test it.
>>
>> And, please update the case, and this mail chain accordingly.
>>
>> --
>>
>> 

[pgadmin-hackers] [pgAdmin4][Patch]: RM1840 - cannot create gist index due to enforced ASC, DESC options in generated SQL

2016-10-19 Thread Surinder Kumar
Hi,

The options like "sort" and "nulls" must be conditional. i.e. include only
when access method type is other than "gist" or "gin".

Please find attached patch and review.

Thanks,
Surinder Kumar


RM1840.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] RM1849: Auto-generating security keys

2016-10-19 Thread Dave Page
I think you'll also need to set the version back to 13 in the version table.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK:http://www.enterprisedb.com
The Enterprise PostgreSQL Company

> On 20 Oct 2016, at 07:00, Murtuza Zabuawala 
>  wrote:
> 
> Could you delete 'keys' table from pgadmin4.db file & try again? 
> 
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
> 
>> On Thu, Oct 20, 2016 at 11:26 AM, Fahar Abbas  
>> wrote:
>> Murtaza,
>> 
>> I have applied this patch and there is no success on new pgAdmin4 setup as 
>> well as existing pgAdmin4 setup.
>> 
>>> On Thu, Oct 20, 2016 at 10:45 AM, Murtuza Zabuawala 
>>>  wrote:
>>> Hi,
>>> 
>>> PFA patch to fix the issue for Pyhton3.
>>> RM#1849
>>> 
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>> 
 On Thu, Oct 20, 2016 at 11:03 AM, Fahar Abbas 
  wrote:
 Hi Dave,
 
 I have reopened following RM:
 
 https://redmine.postgresql.org/issues/1849 
 
> On Wed, Oct 19, 2016 at 6:04 PM, Dave Page  wrote:
> Patch applied.
> 
>> On Wed, Oct 19, 2016 at 11:55 AM, Ashesh Vashi 
>>  wrote:
>> Hi Fahar,
>> 
>> Please log the case on redmine.
>> Please find the attached patch, please apply it locally, and test it.
>> 
>> And, please update the case, and this mail chain accordingly.
>> 
>> --
>> Thanks & Regards,
>> 
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> 
>> http://www.linkedin.com/in/asheshvashi
>> 
>>> On Wed, Oct 19, 2016 at 3:47 PM, Fahar Abbas 
>>>  wrote:
>>> Here is the output of if we copy config_local.py and execute python 
>>> setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>> 
>>> 
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does 
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>> 
>>> 
>>> Enter the email address and password to use for the initial pgAdmin 
>>> user account:
>>> 
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password: 
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> password = encrypt_password(p1)
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py", 
>>> line 150, in encrypt_password
>>> signed = get_hmac(password).decode('ascii')
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py", 
>>> line 108, in get_hmac
>>> 'set to "%s"' % _security.password_hash)
>>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not 
>>> be None when the value of `SECURITY_PASSWORD_HASH` is set to 
>>> "pbkdf2_sha512"
>>> python setup.py
>>> pgAdmin 4 - Application Initialisation
>>> ==
>>> 
>>> User can not do any setup for web based now.
>>> 
>>> 
>>> The configuration database - '/home/fahar/.pgadmin/pgadmin4.db' does 
>>> not exist.
>>> Entering initial setup mode...
>>> NOTE: Configuring authentication for SERVER mode.
>>> 
>>> 
>>> Enter the email address and password to use for the initial pgAdmin 
>>> user account:
>>> 
>>> Email address: fahar.ab...@enterprisedb.com
>>> Password: 
>>> Retype password:
>>> Traceback (most recent call last):
>>>   File "setup.py", line 449, in 
>>> do_setup(app)
>>>   File "setup.py", line 96, in do_setup
>>> password = encrypt_password(p1)
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py", 
>>> line 150, in encrypt_password
>>> signed = get_hmac(password).decode('ascii')
>>>   File 
>>> "/home/fahar/venv/lib/python3.5/site-packages/flask_security/utils.py", 
>>> line 108, in get_hmac
>>> 'set to "%s"' % _security.password_hash)
>>> RuntimeError: The configuration value `SECURITY_PASSWORD_SALT` must not 
>>> be None when the value of `SECURITY_PASSWORD_HASH` is set to 
>>> "pbkdf2_sha512"
>>> 
 On Wed, Oct 19, 2016 at 3:03 PM, Fahar Abbas 
  wrote:
 Dave,
 
 Testing Environment
  
 Ubuntu 16.04 Linux 64:
 
 pg-AdminIV Development Environment Setup for Ubuntu  :
 
 1) Install GIT
 sudo apt-get install git
 2) Install pip3
 sudo apt-get install python3-pip
 3) Install virtualenv
 su

Re: [pgadmin-hackers] [pgAdmin4][Patch]: RM1728 - Properties are not refreshing after objects are edited

2016-10-19 Thread Surinder Kumar
Hi,

While fixing RM1840, I found when we add new index, it doesn't add under
right parent. i.e. columns collection. because wrong parent is given in
response.
I also verified other nodes. This issue is only with index node.

Do, I need to create separate RM for this case. ?

Please find attached minor patch and review.

On Tue, Oct 18, 2016 at 4:03 PM, Dave Page  wrote:

> Thanks - applied!
>
> On Mon, Oct 17, 2016 at 7:48 AM, Surinder Kumar
>  wrote:
> > On Sun, Oct 16, 2016 at 7:29 AM, Dave Page  wrote:
> >>
> >> Hi
> >>
> >> I just found a case where this patch is broken - if you update the
> comment
> >> on a type, it looks like it tried to lookup the schema ID using the type
> >> name, which a) isn't in the posted data so gives a 500 response, and b)
> >> wouldn't be safe anyway, if there were types with the same name in
> multiple
> >> schemas.
> >
> > I have fixed this issue. Now it will lookup the schema ID against the
> type
> > id instead of type name.
> >>
> >>
> >> Actually, it looks like that's an issue when creating a type too - that
> is
> >> also using an unsafe schema lookup.
> >>
> >> Please fix this ASAP (i.e. Monday) and double check to ensure we're not
> >> doing any more unsafe lookups like this.
> >
> > It looks good to me in other nodes.
> > Please find attached patch and review.
> >>
> >>
> >> Thanks.
> >>
> >>
> >> On Friday, October 14, 2016, Dave Page  wrote:
> >>>
> >>> Thanks, applied.
> >>>
> >>> On Friday, October 14, 2016, Surinder Kumar
> >>>  wrote:
> 
>  Hi
> 
>  Following are the issues fixed in nodes:
> 
>  1) If we create/update a node with non-default schema, It should
> return
>  selected schema id in return response. but default schema id is
> returned
>  every time due to which it throws error in properties panel.
>  Fixed in Domains, Collation, Types, Views & Table node.
> 
>  2) Incorrect parent id of object node is returned from nodes method
> due
>  to which wrong parent id is passed while updating object and
>  thus node didn't get refreshed.
>  Fixed in FTS Configuration, FTS Parser nodes.
> 
>  Also, I have kept changes of first patch which are essential to
> refresh
>  node every time. Without that patch nodes properties panel updates
> only
>  sometimes.
> 
>  Please find attached patch. Please review and let me know for
> comments.
> 
>  Thanks
>  Surinder Kumar
> 
> 
> 
>  On Fri, Sep 23, 2016 at 6:00 PM, Dave Page  wrote:
> >
> > Umm, no it wasn't - sorry.
> >
> > I see the same issue with Types. Can you fix that, and check all
> other
> > nodes as well please?
> >
> > Thanks.
> >
> > On Fri, Sep 23, 2016 at 1:29 PM, Dave Page 
> wrote:
> > > Thanks, applied.
> > >
> > > On Fri, Sep 23, 2016 at 12:05 PM, Surinder Kumar
> > >  wrote:
> > >> Hi,
> > >>
> > >> Please find updated patch with changes:
> > >> 1) On debugging through JS files, the issue was in synonym update
> > >> method
> > >> which wasn't returning node object.
> > >> 2) retrieving schema name in node.sql for creating node object in
> > >> update
> > >> method.
> > >>
> > >> Please review and let me know for comments.
> > >>
> > >> On Fri, Sep 23, 2016 at 2:44 PM, Dave Page 
> > >> wrote:
> > >>>
> > >>> Hi
> > >>>
> > >>> On Fri, Sep 23, 2016 at 7:39 AM, Surinder Kumar
> > >>>  wrote:
> > >>> > Hi
> > >>> >
> > >>> > Issue:
> > >>> > on updating node, we deselect and then again select the node
> > >>> > updated to
> > >>> > refresh the panel. but it needs some delay of few milliseconds
> > >>> > between
> > >>> > deselect and select to fix this issue.
> > >>> >
> > >>> > Please find attached patch and review.
> > >>>
> > >>> This does not resolve the issue for me. I tested using a synonym
> to
> > >>> a
> > >>> package on EPAS 9.5, by changing the target package name.
> > >>>
> > >>>
> > >>> --
> > >>> Dave Page
> > >>> Blog: http://pgsnake.blogspot.com
> > >>> Twitter: @pgsnake
> > >>>
> > >>> EnterpriseDB UK: http://www.enterprisedb.com
> > >>> The Enterprise PostgreSQL Company
> > >>
> > >>
> > >
> > >
> > >
> > > --
> > > Dave Page
> > > Blog: http://pgsnake.blogspot.com
> > > Twitter: @pgsnake
> > >
> > > EnterpriseDB UK: http://www.enterprisedb.com
> > > The Enterprise PostgreSQL Company
> >
> >
> >
> > --
> > Dave Page
> > Blog: http://pgsnake.blogspot.com
> > Twitter: @pgsnake
> >
> > EnterpriseDB UK: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> 
> 
> >>>
> >>>
> >>> --
> >>> Dave Page
> >>> Blog: http://pgsnake.blogspot.com
> >>> Twitter: @pgsnake
> >>>
> >>> EnterpriseDB UK: http://www.enterprisedb.com
> >>> The Enterprise PostgreSQL Compa