Spring Boot MSSQL Kerberos身份验证

Spring Boot MSSQL Kerberos身份验证

问题描述:

当前在我的春季启动application.properties文件中,我指定了以下几行以连接到MSSql服务器.

Currently in my spring boot application.properties file, I am specifying following lines to connect to MSSql server.

spring.datasource.url=jdbc:sqlserver://localhost;databaseName=springbootd

spring.datasource.username=sa

spring.datasource.password=Projects@123

我不想使用用户名和密码,而是想使用kerberos对用户进行身份验证,这是我将要进行的所有更改.

Instead of giving username and password, I want to authenticate user using kerberos, what all changes I will have to make.

我尝试搜索JPA官方文档,但找不到任何文档.这里的线索表示赞赏.

I tried searching in the JPA official documentation but could not find any. Leads here are appreciated.

基本上,您需要正确设置krb5.conf文件.您可以通过以下命令并输入密码来验证该配置:

Basically, you need to set up your krb5.conf file properly. You can verify that configuration via the following command and entering your password:

kinit <user-name>

此外,请确保您具有JDBC URL,例如:

Additionally, make sure you have a JDBC URL like:

jdbc:sqlserver://servername=server_name;integratedSecurity=true;authenticationScheme=JavaKerberos;userName=user@REALM;password=****

请参见

See Microsoft JDBC driver documentation for details.

忘记提及启动参数.添加以下JVM参数:

Forgot to mention the startup arguments. Add the following JVM argument:

-Djava.security.krb5.conf=<PATH_TO>/krb5.conf

如果您使用默认的krb5.conf但不是完全确定,我相信这不是必需的.

I believe this is not neccessary if you use the default krb5.conf but not entirely sure.