Skip to content
Snippets Groups Projects
  • dpsutton's avatar
    4069ac4f
    Remove deprecated friend library (#24543) · 4069ac4f
    dpsutton authored
    * Remove deprecated friend library
    
    - friend has two functions we used: bcrypt and bcrypt-verify. Easy to
    lift them into our own namespace with attribution
    - uses simple interop on org.mindrot.jbcrypt.BCrypt to achieve these
    - also brings in other stuff we don't need
    
    ```
    com.cemerick/friend 0.2.3
      X org.mindrot/jbcrypt 0.3m :use-top <- all we care about
      X org.clojure/core.cache 0.6.3 :superseded
        X org.clojure/data.priority-map 0.0.2 :parent-omitted
      . org.openid4java/openid4java-nodeps 0.9.6
        X commons-logging/commons-logging 1.1.1 :older-version
        . net.jcip/jcip-annotations 1.0
      . com.google.inject/guice 2.0
        . aopalliance/aopalliance 1.0
    ```
    
    And we already declare a dependency on 0.4 of this lib
    
    ```
    org.mindrot/jbcrypt 0.4
    ```
    
    This means we can remove openid4, google.inject/guice, aopalliance, etc
    and just keep using the same `BCrypt` java class we have been using this
    whole time. Behavior and classfiles are identical. So very low risk
    
    Want to call out a use of
    
    ```clojure
        (when-not api/*is-superuser?*
          (api/checkp (u.password/bcrypt-verify (str (:password_salt user) old_password) (:password user))
            "old_password"
            (tru "Invalid password")))
    ```
    
    This has the same signature of an existing function in `u.password/verify-password`:
    
    ```clojure
    (defn verify-password
      "Verify if a given unhashed password + salt matches the supplied hashed-password. Returns `true` if matched, `false`
      otherwise."
      ^Boolean [password salt hashed-password]
      ;; we wrap the friend/bcrypt-verify with this function specifically to avoid unintended exceptions getting out
      (boolean (u/ignore-exceptions
                 (bcrypt-verify (str salt password) hashed-password))))
    ```
    
    I did not replace it in this PR so that the diff is essentially
    `creds/<fn>` -> `u.password/<fn>` and very easy to structually see what
    is going on.
    
    But totally makes sense to clean up the usages of these in another pass
    
    * sort ns
    
    * simple tests
    Remove deprecated friend library (#24543)
    dpsutton authored
    * Remove deprecated friend library
    
    - friend has two functions we used: bcrypt and bcrypt-verify. Easy to
    lift them into our own namespace with attribution
    - uses simple interop on org.mindrot.jbcrypt.BCrypt to achieve these
    - also brings in other stuff we don't need
    
    ```
    com.cemerick/friend 0.2.3
      X org.mindrot/jbcrypt 0.3m :use-top <- all we care about
      X org.clojure/core.cache 0.6.3 :superseded
        X org.clojure/data.priority-map 0.0.2 :parent-omitted
      . org.openid4java/openid4java-nodeps 0.9.6
        X commons-logging/commons-logging 1.1.1 :older-version
        . net.jcip/jcip-annotations 1.0
      . com.google.inject/guice 2.0
        . aopalliance/aopalliance 1.0
    ```
    
    And we already declare a dependency on 0.4 of this lib
    
    ```
    org.mindrot/jbcrypt 0.4
    ```
    
    This means we can remove openid4, google.inject/guice, aopalliance, etc
    and just keep using the same `BCrypt` java class we have been using this
    whole time. Behavior and classfiles are identical. So very low risk
    
    Want to call out a use of
    
    ```clojure
        (when-not api/*is-superuser?*
          (api/checkp (u.password/bcrypt-verify (str (:password_salt user) old_password) (:password user))
            "old_password"
            (tru "Invalid password")))
    ```
    
    This has the same signature of an existing function in `u.password/verify-password`:
    
    ```clojure
    (defn verify-password
      "Verify if a given unhashed password + salt matches the supplied hashed-password. Returns `true` if matched, `false`
      otherwise."
      ^Boolean [password salt hashed-password]
      ;; we wrap the friend/bcrypt-verify with this function specifically to avoid unintended exceptions getting out
      (boolean (u/ignore-exceptions
                 (bcrypt-verify (str salt password) hashed-password))))
    ```
    
    I did not replace it in this PR so that the diff is essentially
    `creds/<fn>` -> `u.password/<fn>` and very easy to structually see what
    is going on.
    
    But totally makes sense to clean up the usages of these in another pass
    
    * sort ns
    
    * simple tests
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
snowplow NaN GiB