nette / database

💾 A database layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.
https://doc.nette.org/database
Other
502 stars 107 forks source link

Support short-time passwords (tokens) in connection strings #299

Closed kratkyzobak closed 3 months ago

kratkyzobak commented 1 year ago

There are possibilities to connect database servers using token credentials. For example https://learn.microsoft.com/en-us/azure/mysql/flexible-server/concepts-azure-ad-authentication

tl;dr - there are situations where you can use short-lived token instead of long-lived password to connect to database

Problem(s):

Potential solutions:

I would preffer last one of course. I wanted to do it and send as PR, but I feel like to need approval that it is acceptable at all. As I looked to another frameworks, their configuration usually does not support this scenario too.

JanTvrdik commented 1 year ago

Are there some problem with using the second solution, i.e. having custom connection factory?

kratkyzobak commented 1 year ago

Problem is only in mindset. Of course I can handle solving this by connection factory and/or decorator above current Connection class, where I would re-implement connection laziness.

I belive, this kind of stuff should be somehow supported by framework as short-lived passwords will be used more and more.

But I may be alone with this opinion. This is reason, why I asked first, before trying to create PR.

kratkyzobak commented 3 months ago

Solved by https://github.com/nette/database/commit/abd38ef93eb366e4e661e0012343cc3551f58a17 (moving PDO::connect call from Connection to Driver class). Driver is injectable to Connection, so we can create own Driver without mangling with Connection.