liquibase / docker

Apache License 2.0
64 stars 75 forks source link

Run liquibase in Docker with Integrated Security #339

Open mkucharsky opened 1 month ago

mkucharsky commented 1 month ago

I would like to run liquibase and connect to SQL Server with Integrated Security. I have checked documentation ms-sql-server-windows-integrated-security and prepared command:

liquibase --log-level=FINE status --verbose --changelog-file=sql/changelog.xml --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --url="jdbc:sqlserver://$HOST:1433;IntegratedSecurity=true;databaseName=$DB;trustServerCertificate=true;encrypt=true" --username=$USER --password=$PASS

I use official docker image: liquibase/liquibase:4.29 Unfortunately I get an error:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:edae05fd-1aa8-4120-91d8-7cc60a2d4cbf
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:4266)
        at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<init>(AuthenticationJNI.java:78)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:5345)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$300(SQLServerConnection.java:94)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:5334)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7739)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4384)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3823)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:3348)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:3179)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1953)
        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1263)
        at liquibase.database.jvm.JdbcConnection.open(JdbcConnection.java:42)
        ... 32 more
Caused by: java.lang.UnsatisfiedLinkError: Unable to load authentication DLL mssql-jdbc_auth-12.6.1.x64
        at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<clinit>(AuthenticationJNI.java:67)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:5344)
        ... 42 more

I don’t understand this log, how can I load dll to linux machine and where I should copy this file mssql-jdbc_auth-12.6.1.x64.dll ? How to connect within docker container to mssql server using Integrated Security?

jnewton03 commented 1 month ago

hi @mkucharsky , since the liquibase docker container is based on linux, it won't natively support Windows Integrated Security. Instead you would need to extend the liquibase docker image using Kerberos Authentication. This would involve doing the following:

You can find more detail about this here: https://docs.liquibase.com/start/tutorials/ms-sql-server-integrated-security-kerberos-authentication.html