I currently have a simple Node app that communicates to an Oracle DB and authenticates using Kerberos. The working code looks like this...
oracledb.externalAuth = true;
oracledb.autoCommit = true;
...
get poolConnection(){
return oracledb.createPool({
connectString: this.connectionString
});
}
Notice I don't need username and password. I tried to do this same thing in Scala using Spring-JPA. My configuration looks like this...
spring:
datasource:
url: jdbc:oracle:thin:@//myjdbcurl
validationQuery: SELECT 1
jpa:
show-sql: true
properties:
hibernate:
dialect=org:
hibernate:
dialect:
Oracle10gDialect: org.hibernate.dialect.Oracle10gDialect
and a POM like this...
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.1.0</version>
</dependency>
However, when I try to run I get...
ORA-28040: No matching authentication protocol
How do I handle Kerberos Auth with Oracle and Spring-JPA?
So in my case to get it to work my application.yml looked like this...
spring:
datasource:
url: jdbc:oracle:thin:@//...
validationQuery: select 1 from dual
jpa:
show-sql: true
properties:
hibernate:
naming:
implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
dialect: org.hibernate.dialect.Oracle10gDialect
jdbc:
url: jdbc:oracle:thin:@//...
driver:
class:
name: oracle.jdbc.OracleDrive
and I had to add this to my static main that sets the Spring app...
def main(args: Array[String]) : Unit = {
System.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_SERVICES, "KERBEROS5")
System.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_KRB5_MUTUAL, "true")
System.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_KRB5_CC_NAME, System.getenv("KRB5CCNAME"))
System.setProperty("java.security.krb5.conf", System.getenv("KRB5_CONFIG"))
SpringApplication.run(classOf[Application], args :_ *)
}
I tried adding this to the properties after looking through the code but only the above would work.
#java:
# security:
# krb5:
# conf: ${KRB5_CONFIG}
#oracle:
# net:
# authentication_services: "KERBEROS5"
# kerberos5_mutual_authentication: "true"
# kerberos5_cc_name: ${KRB5_CONFIG}