Skip to content

Commit

Permalink
Merge branch 'Section-11-Video-1' into Section-11-Video-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Xantier committed Jan 13, 2018
2 parents cbe60c3 + 69a990e commit c6f44de
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 34 deletions.
3 changes: 1 addition & 2 deletions backend/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
val kotlinVersion = "1.1.51"
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("org.jetbrains.kotlin.plugin.spring") version "1.2.10"
}
apply {
plugin("org.springframework.boot")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ApiHandler(private val validator: Validator,
}
}

@Suppress("UNUSED_PARAMETER")
fun getProjects(req: ServerRequest) =
ServerResponse.ok().body(
Mono.just(projectService.fetchProjects().map { it.toDto() })
Expand All @@ -47,6 +48,7 @@ class ApiHandler(private val validator: Validator,
}
}

@Suppress("UNUSED_PARAMETER")
fun getOwners(req: ServerRequest): Mono<ServerResponse> =
ServerResponse.ok().body(Mono.just(projectService.fetchAllOwners()))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ExceptionHandler : WebExceptionHandler, WithLogging() {
Validatable(genericError = throwable.localizedMessage))
}

private fun respond(httpStatus: HttpStatus, body: Any?):
private fun respond(httpStatus: HttpStatus, body: Any):
Mono<ServerResponse> =
ServerResponse
.status(httpStatus)
Expand Down
5 changes: 3 additions & 2 deletions backend/api/src/main/kotlin/com/packtpub/util/Logging.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.packtpub.util

import org.apache.log4j.Logger
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import kotlin.reflect.KClass
import kotlin.reflect.full.companionObject


// Return logger for Java class, if companion object fix the name
fun <T : Any> logger(forClass: Class<T>): Logger {
return Logger.getLogger(unwrapCompanionClass(forClass).name)
return LogManager.getLogger(unwrapCompanionClass(forClass).name)
}

// unwrap companion class to enclosing class given a Java Class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlinx.html.*
import kotlinx.html.stream.createHTML


fun index(header: String, projects: List<ProjectView>): String {
fun index(@Suppress("UNUSED_PARAMETER") header: String, @Suppress("UNUSED_PARAMETER") projects: List<ProjectView>): String {
return createHTML(true).html {
head {
title = "Full Stack Kotlin"
Expand Down
4 changes: 2 additions & 2 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile


plugins {
kotlin("jvm", "1.1.51")
kotlin("jvm") version "1.2.10"
}

buildscript {
Expand All @@ -27,7 +27,7 @@ subprojects {
}

plugins {
kotlin("jvm", kotlinVersion)
kotlin("jvm") version kotlinVersion
}

apply {
Expand Down
5 changes: 2 additions & 3 deletions backend/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
springBootVersion=2.0.0.BUILD-SNAPSHOT
springSecurityVersion=5.0.0.BUILD-SNAPSHOT
kotlinVersion=1.1.51
springBootVersion=2.0.0.M7
kotlinVersion=1.2.10
hibernateValidatorVersion=6.0.2.Final
postgresVersion=42.1.4
5 changes: 2 additions & 3 deletions backend/project/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
val kotlinVersion = "1.1.51"
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
id("org.jetbrains.kotlin.plugin.spring") version "1.2.10"
id("org.jetbrains.kotlin.plugin.jpa") version "1.2.10"
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion backend/project/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kotlinJacksonVersion=2.9.0
kotlinJacksonVersion=2.9.0
8 changes: 3 additions & 5 deletions backend/user/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
plugins {
val kotlinVersion = "1.1.51"
val kotlinVersion = "1.2.10"
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
}

dependencies {
val springBootVersion: String = parent!!.properties["springBootVersion"] as String
val springSecurityVersion: String = parent!!.properties["springSecurityVersion"] as String
val postgresVersion: String = parent!!.properties["postgresVersion"] as String
compile("org.springframework.boot:spring-boot-starter:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-webflux:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-security:$springBootVersion")
compile("org.postgresql:postgresql:$postgresVersion")
compile("org.springframework.security:spring-security-core:$springSecurityVersion")
compile("org.springframework.security:spring-security-config:$springSecurityVersion")
compile("org.springframework.security:spring-security-webflux:$springSecurityVersion")
}
16 changes: 8 additions & 8 deletions backend/user/src/main/kotlin/com/packtpub/UserConfig.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.packtpub

import org.springframework.context.support.BeanDefinitionDsl
import org.springframework.security.authentication.UserDetailsRepositoryAuthenticationManager
import org.springframework.security.config.web.server.HttpSecurity
import org.springframework.security.core.userdetails.UserDetailsRepository
import org.springframework.security.authentication.ReactiveAuthenticationManager
import org.springframework.security.config.web.server.ServerHttpSecurity
import org.springframework.security.core.userdetails.ReactiveUserDetailsService
import org.springframework.security.web.server.SecurityWebFilterChain
import reactor.core.publisher.Mono
import reactor.core.publisher.toMono


fun BeanDefinitionDsl.securityBeans(paths: HttpSecurity.AuthorizeExchangeBuilder
.(SecurityService) -> HttpSecurity.AuthorizeExchangeBuilder) {
fun BeanDefinitionDsl.securityBeans(paths: ServerHttpSecurity.AuthorizeExchangeSpec
.(SecurityService) -> ServerHttpSecurity.AuthorizeExchangeSpec) {
bean<UserRepository>()
bean<UserService> {
UserServiceImpl(ref())
Expand All @@ -19,7 +19,7 @@ fun BeanDefinitionDsl.securityBeans(paths: HttpSecurity.AuthorizeExchangeBuilder
SecurityServiceImpl()
}
bean {
UserDetailsRepository { username ->
ReactiveUserDetailsService { username ->
ref<UserService>().getUserByName(username)
?.toUserDetails()
?.toMono()
Expand All @@ -29,11 +29,11 @@ fun BeanDefinitionDsl.securityBeans(paths: HttpSecurity.AuthorizeExchangeBuilder
}
}
bean<SecurityWebFilterChain> {
HttpSecurity.http().authorizeExchange()
ServerHttpSecurity.http().authorizeExchange()
.paths(ref())
.anyExchange().authenticated()
.and()
.authenticationManager(UserDetailsRepositoryAuthenticationManager(ref()))
.authenticationManager(ReactiveAuthenticationManager(ref()))
.formLogin()
.and()
.build()
Expand Down
4 changes: 1 addition & 3 deletions config/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/fullstack_kotlin
spring.datasource.username=kotlin
spring.datasource.password=salasana
spring.jpa.hibernate.ddl-auto=update

# API ENDPOINT
api.endpoint.url=https://api.github.com
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL9Dialect
2 changes: 1 addition & 1 deletion frontend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ configure<KotlinFrontendExtension>{
configure<NpmExtension> {
replaceVersion("kotlinx-html-js", "0.6.4")
replaceVersion("kotlinx-html-shared", "0.6.4")
replaceVersion("kotlin-js-library", "1.1.51")
replaceVersion("kotlin-js-library", "1.2.10")

dependency("react", "16.0.0")
dependency("react-dom", "16.0.0")
Expand Down
2 changes: 1 addition & 1 deletion frontend/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kotlinVersion=1.1.51
kotlinVersion=1.2.10
frontendPluginVersion=0.0.21
kotlinxHtmlVersion=0.6.4
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip

0 comments on commit c6f44de

Please sign in to comment.