Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#12 Basic frontend features #56

Merged
merged 12 commits into from
Nov 14, 2024
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#ide
.idea
itmo-dating.iml
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*.zip
*.tar.gz
*.rar
*.pem

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
Expand Down
9 changes: 9 additions & 0 deletions backend/authik/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM eclipse-temurin:21-jdk-alpine

WORKDIR /matchmaker

COPY ./build/libs/authik-1.0.0.jar ./authik.jar

EXPOSE 8080

CMD ["java", "-jar", "authik.jar"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.ifmo.se.dating.authik.telegram

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import org.apache.commons.codec.digest.HmacUtils
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
Expand All @@ -12,11 +13,12 @@ import ru.ifmo.se.dating.validation.expect

@Component
class InitDataParser(
private val jackson: ObjectMapper,

@Value("\${security.auth.telegram.token}")
telegramToken: String,
) {
private val jackson = jacksonObjectMapper().apply {
registerKotlinModule()
}
private val algorithm = "HmacSHA256"
private val hmac =
HmacUtils(algorithm, HmacUtils(algorithm, "WebAppData").hmac(telegramToken))
Expand Down
14 changes: 14 additions & 0 deletions backend/authik/src/main/resources/static/openapi/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,28 @@ components:
type: string
maxLength: 128
minLength: 1
nullable: true
last_name:
type: string
maxLength: 128
minLength: 1
nullable: true
username:
type: string
maxLength: 128
minLength: 1
language_code:
type: string
maxLength: 10
minLength: 1
nullable: true
allows_write_to_pm:
type: boolean
nullable: true
photo_url:
type: string
maxLength: 256
nullable: true
required:
- id
- first_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class HttpMonitoringApiTest : AuthikTestSuite() {
private lateinit var rest: TestRestTemplate

@Test
fun emptyTest() = Unit

// TODO write test with https
// @Test
fun healthcheck() {
Assert.assertEquals(getHealthcheck(), "public")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extra["generateOAPIServer"] = { serviceName: String ->
"delegatePattern" to "true",
"useSpringBoot3" to "true",
"reactive" to "true",
"serializationLibrary" to "jackson"
)
}

Expand Down
1 change: 1 addition & 0 deletions backend/config/env/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ITMO_DATING_TOKEN_SIGN_KEY_PUBLIC="RSA:MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCA
ITMO_DATING_AUTHIK_POSTGRES_DB="postgres"
ITMO_DATING_AUTHIK_POSTGRES_USER="postgres"
ITMO_DATING_AUTHIK_POSTGRES_PASSWORD="postgres"
ITMO_DATING_AUTHIK_TELEGRAM_BOT_TOKEN="bot_token_here"
ITMO_DATING_AUTHIK_TOKEN_SIGN_KEY_PRIVATE="RSA:MIIG/QIBADANBgkqhkiG9w0BAQEFAASCBucwggbjAgEAAoIBgQCucrDdhxHdYl4tbrgnqBz7x1P+m2Xg6LWR1+CJvURAEmaI1WbODHqGeZ/rQyFMJs8d4qFsErOjPIWVug7fYCrHk19vRQBTayyX32242LxHZWxhvLrCSiDnwaAWJ198qiF2FaM5lpresE0jUPwJBdySTlZbh4V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7Qv0g="

ITMO_DATING_MATCHMAKER_POSTGRES_DB="postgres"
Expand Down
1 change: 1 addition & 0 deletions backend/foundation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {

api(libs.jakarta.validation.jakarta.validation.api)
api(libs.com.fasterxml.jackson.core.jackson.databind)
api(libs.com.fasterxml.jackson.module.jackson.module.kotlin)

api(libs.org.jetbrains.kotlinx.kotlinx.coroutines.reactor)
api(libs.io.projectreactor.kotlin.reactor.kotlin.extensions)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ru.ifmo.se.dating.spring

import org.springframework.http.HttpMethod
import org.springframework.http.HttpStatus
import org.springframework.stereotype.Component
import org.springframework.web.server.ServerWebExchange
import org.springframework.web.server.WebFilter
import org.springframework.web.server.WebFilterChain
import reactor.core.publisher.Mono

@Component
class CorsFilter : WebFilter {
// FIXME
override fun filter(ctx: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
ctx.response.headers.add("Access-Control-Allow-Origin", "*")
ctx.response.headers.add("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, OPTIONS")
Comment on lines +15 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сюда еще лучше FIXME поставить, чтобы мы когда-нибудь разобрались с этим нормально.

ctx.response.headers.add(
"Access-Control-Allow-Headers",
"DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With," +
"If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"
Comment on lines +19 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это лучше запихнуть в список, а потом сделать join(',') в String.

)
if (ctx.request.method == HttpMethod.OPTIONS) {
ctx.response.headers.add("Access-Control-Max-Age", "1728000")
ctx.response.statusCode = HttpStatus.NO_CONTENT
return Mono.empty()
} else {
ctx.response.headers.add(
"Access-Control-Expose-Headers",
"DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With," +
"If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"
)
return chain.filter(ctx) ?: Mono.empty()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
server:
port: 8080
ssl:
certificate: "classpath:cert.pem"
certificate-private-key: "classpath:privkey.pem"
trust-certificate: "classpath:chain.pem"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А где оно лежит? Если в директории resources, то можно не указывать classpath. В кавычки брать тоже необязательно.

spring:
datasource:
driver-class-name: org.postgresql.Driver
Expand Down
6 changes: 4 additions & 2 deletions backend/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ org-liquibase-liquibase-core = "4.29.2"
org-postgresql-postgresql = "42.7.4"
org-postgresql-r2dbc-postgresql = "1.0.7.RELEASE"

com-fasterxml-jackson-core-jackson-databind = "2.18.1"
com-fasterxml-jackson = "2.18.1"

jakarta-validation-jakarta-validation-api = "3.1.0"
commons-codec-commons-codec = "1.17.1"

Expand Down Expand Up @@ -44,7 +45,8 @@ io-jsonwebtoken-jjwt-impl = { module = "io.jsonwebtoken:jjwt-impl", version.ref
io-jsonwebtoken-jjwt-jackson = { module = "io.jsonwebtoken:jjwt-jackson", version.ref = "io-jsonwebtoken" }

jakarta-validation-jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation-jakarta-validation-api" }
com-fasterxml-jackson-core-jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "com-fasterxml-jackson-core-jackson-databind" }
com-fasterxml-jackson-core-jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "com-fasterxml-jackson" }
com-fasterxml-jackson-module-jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "com-fasterxml-jackson" }
commons-codec-commons-codec = { module = "commons-codec:commons-codec", version.ref = "commons-codec-commons-codec" }

org-jetbrains-kotlinx-kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "org-jetbrains-kotlinx-kotlinx-coroutines" }
Expand Down
9 changes: 9 additions & 0 deletions backend/matchmaker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM eclipse-temurin:21-jdk-alpine

WORKDIR /matchmaker

COPY ./build/libs/matchmaker-1.0.0.jar ./matchmaker.jar

EXPOSE 8080

CMD ["java", "-jar", "matchmaker.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class HttpMonitoringApiTest : MatchmakerTestSuite() {
private lateinit var rest: TestRestTemplate

@Test
fun emptyTest() = Unit

// TODO write test with https
// @Test
fun healthcheck() {
Assert.assertEquals(getHealthcheck(), "public")
}
Expand Down
9 changes: 9 additions & 0 deletions backend/people/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM eclipse-temurin:21-jdk-alpine

WORKDIR /people

COPY ./build/libs/people-1.0.0.jar ./people.jar

EXPOSE 8080

CMD ["java", "-jar", "people.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class HttpMonitoringApiTest : PeopleTestSuite() {
private lateinit var rest: TestRestTemplate

@Test
fun emptyTest() = Unit

// TODO write test with https
// @Test
fun healthcheck() {
Assert.assertEquals(getHealthcheck(), "public")
}
Expand Down
18 changes: 6 additions & 12 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
services:
authik:
image: eclipse-temurin:21-jdk-alpine
volumes:
- ./backend/authik/build/libs/authik-1.0.0.jar:/authik.jar
command: java -jar /authik.jar
build:
context: ./backend/authik
environment:
POSTGRES_DB: ${ITMO_DATING_AUTHIK_POSTGRES_DB?:err}
POSTGRES_USER: ${ITMO_DATING_AUTHIK_POSTGRES_USER?:err}
Expand All @@ -28,10 +26,8 @@ services:
timeout: 1s
retries: 16
matchmaker:
image: eclipse-temurin:21-jdk-alpine
volumes:
- ./backend/matchmaker/build/libs/matchmaker-1.0.0.jar:/matchmaker.jar
command: java -jar /matchmaker.jar
build:
context: ./backend/matchmaker
environment:
POSTGRES_DB: ${ITMO_DATING_MATCHMAKER_POSTGRES_DB?:err}
POSTGRES_USER: ${ITMO_DATING_MATCHMAKER_POSTGRES_USER?:err}
Expand All @@ -53,10 +49,8 @@ services:
timeout: 1s
retries: 16
people:
image: eclipse-temurin:21-jdk-alpine
volumes:
- ./backend/people/build/libs/people-1.0.0.jar:/people.jar
command: java -jar /people.jar
build:
context: ./backend/people
environment:
POSTGRES_DB: ${ITMO_DATING_PEOPLE_POSTGRES_DB?:err}
POSTGRES_USER: ${ITMO_DATING_PEOPLE_POSTGRES_USER?:err}
Expand Down
4 changes: 4 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# production
/build
/dist
/.cert

# misc
.DS_Store
Expand All @@ -20,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

#ide
frontend.iml
2 changes: 2 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPY package*.json ./

RUN npm install

COPY .cert ./.cert

COPY dist ./dist

COPY vite.config.ts .
Expand Down
Loading
Loading