Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ws/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ dependencies {
}
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("com.yahoo.elide", "elide-spring-boot-starter", "5.0.2")
implementation("com.yahoo.elide", "elide-spring-boot-starter", "5.0.9")
implementation("org.projectlombok", "lombok", "1.18.20")
implementation("com.h2database", "h2", "1.3.176")
implementation("net.rakugakibox.spring.boot:logback-access-spring-boot-starter:2.7.1")
// drivers for models
runtimeOnly("org.apache.hive","hive-jdbc","3.1.2"){
exclude(group="org.apache.logging.log4j", module = "log4j-slf4j-impl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@

package com.yahoo.yavin.ws.security

import lombok.extern.slf4j.Slf4j
import org.slf4j.MDC
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.security.core.userdetails.UsernameNotFoundException
import org.springframework.stereotype.Service

@Service
@Slf4j
class UserDetailsService(private val userRepository: UserRepository) :
UserDetailsService {

override fun loadUserByUsername(username: String): UserDetails {
val user = userRepository.findOneById(username) ?: throw UsernameNotFoundException("User Not Found!")
MDC.put("user", user.id)
return UserDetails(user)
}
}
3 changes: 3 additions & 0 deletions ws/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ spring:
ddl-auto: 'none'
jdbc:
use_scrollable_resultset: true
properties:
hibernate:
default_batch_fetch_size: 100
datasource:
url: 'jdbc:h2:file:./build/yavin;DB_CLOSE_DELAY=-1'
username: 'navidev'
Expand Down
2 changes: 1 addition & 1 deletion ws/src/main/resources/logback-access-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%t{yyyy-MM-dd:HH:mm:ss Z} %remoteIP %user %requestURL %statusCode %bytesSent %elapsedTime %header{X-B3-TraceId} %requestContent %responseContent</pattern>
<pattern>%t{yyyy-MM-dd:HH:mm:ss Z} %remoteIP %user %requestURL %statusCode %bytesSent %elapsedTime %header{X-B3-TraceId} %requestContent</pattern>
</encoder>
</appender>

Expand Down
9 changes: 6 additions & 3 deletions ws/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<appender name="LOGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDir}/server.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] [${springAppName}, %X{X-B3-TraceId:-}] %-5level %logger{36}.%M - %msg%n</Pattern>
<Pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] [${springAppName}, %X{X-B3-TraceId:-}] %-5level %logger{36}.%M %mdc{user} - %msg%n</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDir}/archived/server_%d{yyyy-MM-dd}.log</fileNamePattern>
Expand All @@ -26,7 +26,10 @@
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />

<!-- Log JPA Datastore HQL Statements -->
<logger name="com.yahoo.elide.datastores.jpa.porting.EntityManagerWrapper" level="DEBUG" />
<logger name="com.yahoo.elide.core.hibernate.hql.DefaultQueryLogger" level="DEBUG" />

<!-- Log SQL/JPQL Timings -->
<logger name="com.yahoo.elide.core.utils.TimedFunction" level="DEBUG" />

<!-- Log HTTP Error Explanations -->
<logger name="com.yahoo.elide.graphql.QueryRunner" level="DEBUG" />
Expand All @@ -36,4 +39,4 @@
<appender-ref ref="STDOUT" />
<appender-ref ref="LOGFILE" />
</root>
</configuration>
</configuration>