Skip to content

Commit

Permalink
Quick fix for redirect to COSV on authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
orchestr7 committed Oct 18, 2023
1 parent 2459d8a commit 5f28a45
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions api-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ spring:
huawei:
provider: huawei
# hardcoded as for gitee
redirect-uri: 'https://cosv.gitlink.org.cn/login/oauth2/code/huawei'
redirect-uri: '{baseUrl}/login/oauth2/code/huawei'
authorization-grant-type: authorization_code
client-authentication-method: client_secret_post
# can be
Expand All @@ -130,7 +130,7 @@ spring:
provider: gitee
# it can be '${gateway.frontend.url}/{action}/oauth2/code/{registrationId}',
# but for security reasons I would like to hardcode a domain name
redirect-uri: 'https://cosv.gitlink.org.cn/login/oauth2/code/gitee'
redirect-uri: '{baseUrl}/login/oauth2/code/gitee'
authorization-grant-type: authorization_code
scope:
- user_info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ enum class FrontendRoutes(val path: String) {
THANKS_FOR_REGISTRATION("thanks-for-registration"),
VULN("vuln"),
VULNERABILITIES("$VULN/list"),
VULNERABILITY_SINGLE("$VULN/collection"),
VULN_COSV_SCHEMA("$VULN/schema"),
VULN_CREATE("$VULN/create-vulnerability"),
VULN_PROFILE("$VULN/profile"),
VULNERABILITY_SINGLE("$VULN/collection"),
VULN_TOP_RATING("$VULN/top-rating"),
VULN_UPLOAD("$VULN/upload-vulnerability"),
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.saveourtool.save.frontend.utils.TopBarUrl
import com.saveourtool.save.frontend.utils.isCosvDomain
import com.saveourtool.save.utils.URL_PATH_DELIMITER
import com.saveourtool.save.validation.FrontendRoutes
import kotlinx.browser.window

import react.FC
import react.Props
Expand All @@ -21,6 +20,8 @@ import react.router.dom.Link
import remix.run.router.Location
import web.cssom.ClassName

import kotlinx.browser.window

/**
* Displays the URL split with "/".
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package com.saveourtool.save.frontend.utils
import com.saveourtool.save.domain.Role
import com.saveourtool.save.domain.Role.SUPER_ADMIN
import com.saveourtool.save.info.UserInfo
import kotlinx.browser.window

import org.w3c.dom.Location
import org.w3c.files.Blob
import org.w3c.files.BlobPropertyBag
import org.w3c.xhr.FormData
Expand All @@ -32,7 +32,6 @@ import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.LocalTime
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.w3c.dom.Location

private const val BYTES_COEFFICIENT = 1024

Expand Down Expand Up @@ -137,6 +136,14 @@ fun String.dateStringToLocalDateTime(time: LocalTime = LocalTime(0, 0, 0)) = Loc
time,
)

/**
* Dirty hack for the COSV location
* Should be removed in future
*
* @return true if we are in COSV domains range
*/
fun Location.isCosvDomain() = this.hostname in setOf("cosv.dev", "cosv.gitlink.org.cn")

/**
* @return `true` if this user is a super-admin, `false` otherwise.
* @see Role.isSuperAdmin
Expand Down Expand Up @@ -213,11 +220,3 @@ internal fun Long.toKiloBytes() = div(BYTES_COEFFICIENT)
* @return converts bytes to megabytes
*/
internal fun Long.toMegabytes() = toDouble().div(BYTES_COEFFICIENT * BYTES_COEFFICIENT)

/**
* Dirty hack for the COSV location
* Should be removed in future
*
* @return true if we are in COSV domains range
*/
fun Location.isCosvDomain() = this.hostname in setOf("cosv.dev", "cosv.gitlink.org.cn") }

0 comments on commit 5f28a45

Please sign in to comment.