How do I avoid having the database password stored in plaintext in sourcecode?

前端 未结 6 1595
情书的邮戳
情书的邮戳 2021-01-01 12:17

In the web-application I\'m developing I currently use a naive solution when connecting to the database:

Connection c = DriverManager.getConnection(\"url\",          


        
6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 12:19

    Unless I am missing the point the connection should be managed by the server via a connection pool, therefore the connection credentials are held by the server and not by the app.

    Taking this further I generally build to a convention where the frontend web application (in a DMZ) only talks to the DB via a web service (in domain), therefore providing complete separation and enhanced DB security.

    Also, never give priviliges to the db account over or above what is essentially needed.

    An alternative approach is to perform all operations via stored procedures, and grant the application user access only to these procs.

提交回复
热议问题