Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I secure my "hibernate.cfg.xml" file? (Nhibernate)

How do I secure my "hibernate.cfg.xml" file? (Nhibernate). It currently sits in the route of the web app and can be viewed via the browser.

like image 960
Andrew Avatar asked Oct 11 '10 10:10

Andrew


People also ask

What is Hibernate CFG XML file?

Hibernate Configuration File(cfg file) is the file loaded into an hibernate application when working with hibernate. Hibernate uses this file to establish connection to the database server.It is an XML file which is used to define below information. Standard name for this file is hibernate. cfg. xml.

Where should I put Hibernate CFG XML?

Let us create hibernate. cfg. xml configuration file and place it in the root of your application's classpath. You will have to make sure that you have testdb database available in your MySQL database and you have a user test available to access the database.

Is it mandatory to have this option in Hibernate CFG XML?

Basically you are setting all the required properties via your properties object so there is no real need to tell Hibernate to look for a hibernate. cfg. xml file which is exactly what the configure() method does. it's not mandatory to use hibernate.

Can we change Hibernate CFG XML file name?

Yes, you can.


1 Answers

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="hibernate.cfg.xml"
           type="System.Web.HttpForbiddenHandler"/>
    </httpHandlers>
  </system.web>
<configuration>
like image 56
Diego Mijelshon Avatar answered Oct 13 '22 13:10

Diego Mijelshon