Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Instructor's can't tell if/when a student (last) changed password (M) #25

Open

Description

@smurthys

Presently, there is no way for an instructor to learn if/when a student (last) changed their password. I wonder if an event trigger or a log entry provides the information required to discover pwd-change activity.

I was hoping ALTER ROLE is an event trigger, but it doesn't appear to be.

Activity

  1. afig commented on Jun 19, 2017

    @afig
    Contributor

    I found two potential ways of doing this, but neither is 100% ideal:

    1. Store the MD5 hash of the initial password that was set for the user. That way, it would be possible to compare it to the hash of the current password from pg_authid to see if it was changed. This would also allow a password reset function to reset the password to the actual "initial password", if one was given. (Instead of only being capable of resetting it to an ID/username.)

    2. The xmin column stores the transaction id of the transaction that last modified a certain row. The pg_authid system table also has an xmin column. We can store the value of the xmin column from the initial role creation, and compare it to the current value to see if the role has been modified. We could also update the stored xmin value whenever a password is reset.

    Both of these solutions require read access to the pg_authid table, which is only available to superuser roles. Also, these solutions only tell if a student changed their password, not when.

    Overall, the first solution seems to be a bit better since it provides extra functionality to a passwordReset function. However, it does take up a bit more storage space since the entire MD5 hash has to be stored (32 chars). Also, the second solution would incorrectly report that the password has been changed if the corresponding row in pg_authid was modified for another reason, or if a user happen to change their password to the same password.

  2. smurthys commented on Jun 22, 2017

    @smurthys
    MemberAuthor

    I like Approach 1 @afig lists. A function such as isInitialPassword(username) (not sure of the function's name) is probably also required to test if a user's current pwd is the same as the initial pwd.

    If we don't want to store the pwd (and I don't prefer storing it), the proposed function can just test the current pwd against user name with the assumption that the initial password is always the user name.

    Vote.

  3. afig commented on Jun 23, 2017

    @afig
    Contributor

    I also prefer the first approach.

    When you say not storing the passwords, are you referring to just the cleartext password or also the MD5 hashes? If we assume that the initial password is always the username and do not store even the MD5 hashes, then the isInitialPassword function will not be able to check for a pw change if an initial password was given during user creation, which could create confusion.

    Another issue with checking with just the username is that the MD5 hash appears to have a salt added. It seems to be the password concatenated with the username, however we should confirm if this is documented somewhere:

    postgres=# ALTER ROLE role1 ENCRYPTED PASSWORD 'password';
    ALTER ROLE
    postgres=# SELECT rolname, rolpassword FROM pg_authid WHERE rolname = 'role1';
     rolname |             rolpassword
    ---------+-------------------------------------
     role1   | md53cc7f7650262f2d46c81337be1b76ec4
    (1 row)
    
    
    postgres=# SELECT md5('password');
                   md5
    ----------------------------------
     5f4dcc3b5aa765d61d8327deb882cf99
    (1 row)
    
    
    postgres=# SELECT md5('passwordrole1');
                   md5
    ----------------------------------
     3cc7f7650262f2d46c81337be1b76ec4
    (1 row)
    

    On a related note, PostgreSQL 10 (expected to be released in Sep 2017) removes support for unencrypted passwords, so we should not create a solution that relies on being able to check for an unencrypted password in pg_authid.

  4. smurthys commented on Jun 25, 2017

    @smurthys
    MemberAuthor

    I meant storing the pwd's hash. Because us storing pwd in any form is a security risk and after learning that Postgres stores pwd hash with a salt, I propose we consider triggers or logs to determine if/when pwd was last changed.

  5. smurthys commented on Dec 28, 2017

    @smurthys
    MemberAuthor

    After using ClassDB for the last few months, I feel it is OK if it is not possible to know when a pwd was last changed: It can be helpful to know, but it is not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions