Skip to content

Commit

Permalink
Merge branch 'main' into feature/91-vylepšení-pipeline
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/build-frontend.yml
#	.github/workflows/deploy-app.yml
  • Loading branch information
MocStepan committed May 23, 2024
2 parents 4631ca0 + 77d799c commit ba63d1f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: [ "main" ]

jobs:
build:
frontend:
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}
branch: 'main'
appdir: 'backend'
procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod'

Expand All @@ -28,4 +29,5 @@ jobs:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{ secrets.HEROKU_FRONTEND_NAME }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}
branch: 'main'
appdir: 'frontend'
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Component
import org.springframework.web.filter.OncePerRequestFilter


@Component
class JwtAuthenticationFilter(
private val tokenFilter: TokenFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.tul.backend.auth.base.dto.ErrorDTO
import com.tul.backend.auth.base.valueobject.AuthUserRole
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.MediaType
Expand All @@ -25,7 +26,8 @@ import org.springframework.web.cors.CorsConfigurationSource
@EnableMethodSecurity
class SecurityConfiguration(
private val objectMapper: ObjectMapper,
private val jwtAuthenticationFilter: JwtAuthenticationFilter
private val jwtAuthenticationFilter: JwtAuthenticationFilter,
@Value("\${spring.jwt.frontendUrl}") private val frontendUrl: String
) {

private val userUnsecuredEndpoints =
Expand Down Expand Up @@ -76,6 +78,7 @@ class SecurityConfiguration(
allowedHeaders = listOf("*")
exposedHeaders = listOf("Content-Disposition")
allowedOriginPatterns = listOf("*")
allowedOrigins = listOf(frontendUrl)
allowCredentials = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.jsonwebtoken.Jwts
import io.jsonwebtoken.io.Decoders
import io.jsonwebtoken.security.Keys


class JwtService(
secret: String
) {
Expand Down Expand Up @@ -37,4 +36,4 @@ class JwtService(
null
}
}
}
}
1 change: 1 addition & 0 deletions backend/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ spring:
sameSite: "Lax"
duration: 86400000 # 1 day
secret: ${JWT_SECRET}
frontendUrl: ${FRONTEND_URL}
1 change: 1 addition & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ spring:
sameSite: "Lax"
duration: 86400000 # 1 day
secret: "7A25432A462D4A614E645267556B58703272357538782F413F4428472B4B6250" # random string in base64, should be changed in production
frontendUrl: "http://localhost:4200"
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class SecurityConfigurationTests : FeatureSpec({
val jwtAuthenticationFilter = mockk<JwtAuthenticationFilter>()

val securityConfiguration = SecurityConfiguration(
objectMapper,
jwtAuthenticationFilter
objectMapper,
jwtAuthenticationFilter,
"http://localhost:4200"
)

val httpSecurity = mockk<HttpSecurity>()
Expand All @@ -50,8 +51,9 @@ class SecurityConfigurationTests : FeatureSpec({
val jwtAuthenticationFilter = mockk<JwtAuthenticationFilter>()

val securityConfiguration = SecurityConfiguration(
objectMapper,
jwtAuthenticationFilter
objectMapper,
jwtAuthenticationFilter,
"http://localhost:4200"
)
val errorDTO = ErrorDTO("Unauthorized")

Expand All @@ -76,4 +78,4 @@ class SecurityConfigurationTests : FeatureSpec({
response.status shouldBe HttpServletResponse.SC_UNAUTHORIZED
}
}
})
})
2 changes: 1 addition & 1 deletion frontend/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const environment = {
baseUrl: 'https://moc-backend-weather-app-d8c5764193db.herokuapp.com/',
baseUrl: 'https://www.weather-app-backend.moc-backend.cz/',
production: true,
version: '1.0.0'
};

0 comments on commit ba63d1f

Please sign in to comment.