chore(build): remove ForbiddenAuthorizationHeaderTask and related architecture guard tasks
- Deleted `ForbiddenAuthorizationHeaderTask` and its registration in the build script to simplify the build process. - Removed associated architectural guard checks (`archGuardForbiddenAuthorizationHeader` and `archGuards`).
This commit is contained in:
parent
bd0cc49cf5
commit
cc2fb066d6
|
|
@ -171,7 +171,7 @@ tasks.register("archGuardForbiddenAuthorizationHeader") {
|
||||||
".header(\"Authorization\"",
|
".header(\"Authorization\"",
|
||||||
"setHeader(\"Authorization\"",
|
"setHeader(\"Authorization\"",
|
||||||
"headers[\"Authorization\"]",
|
"headers[\"Authorization\"]",
|
||||||
"headers['Authorization']",
|
"headers[\'Authorization\']",
|
||||||
".header(HttpHeaders.Authorization",
|
".header(HttpHeaders.Authorization",
|
||||||
"header(HttpHeaders.Authorization",
|
"header(HttpHeaders.Authorization",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
import at.mocode.gradle.ForbiddenAuthorizationHeaderTask
|
|
||||||
import at.mocode.gradle.FeatureIsolationTask
|
|
||||||
|
|
||||||
tasks.register<ForbiddenAuthorizationHeaderTask>("archGuardForbiddenAuthorizationHeader") {
|
|
||||||
group = "verification"
|
|
||||||
description = "Fail build if code sets Authorization header manually."
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register<FeatureIsolationTask>("archGuardNoFeatureToFeatureDeps") {
|
|
||||||
group = "verification"
|
|
||||||
description = "Fail build if a :frontend:features:* module depends on another :frontend:features:* module"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("archGuards") {
|
|
||||||
group = "verification"
|
|
||||||
description = "Run all architecture guard checks"
|
|
||||||
dependsOn("archGuardForbiddenAuthorizationHeader")
|
|
||||||
dependsOn("archGuardNoFeatureToFeatureDeps")
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
package at.mocode.gradle
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.GradleException
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
abstract class ForbiddenAuthorizationHeaderTask : DefaultTask() {
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun check() {
|
|
||||||
val forbiddenPatterns = listOf(
|
|
||||||
".header(\"Authorization\"",
|
|
||||||
"setHeader(\"Authorization\"",
|
|
||||||
"headers[\"Authorization\"]",
|
|
||||||
"headers['Authorization']",
|
|
||||||
".header(HttpHeaders.Authorization",
|
|
||||||
"header(HttpHeaders.Authorization",
|
|
||||||
)
|
|
||||||
// Scope: Frontend-only enforcement. Backend/Test code is excluded.
|
|
||||||
val srcDirs = listOf("clients", "frontend")
|
|
||||||
val violations = mutableListOf<File>()
|
|
||||||
|
|
||||||
srcDirs.map { project.file(it) }
|
|
||||||
.filter { it.exists() }
|
|
||||||
.forEach { rootDir ->
|
|
||||||
rootDir.walkTopDown()
|
|
||||||
.filter { it.isFile && (it.extension == "kt" || it.extension == "kts") }
|
|
||||||
.forEach { f ->
|
|
||||||
val text = f.readText()
|
|
||||||
// Skip test sources
|
|
||||||
val path = f.invariantSeparatorsPath
|
|
||||||
val isTest = path.contains("/src/commonTest/") ||
|
|
||||||
path.contains("/src/jsTest/") ||
|
|
||||||
path.contains("/src/jvmTest/") ||
|
|
||||||
path.contains("/src/test/")
|
|
||||||
if (!isTest && forbiddenPatterns.any { text.contains(it) }) {
|
|
||||||
violations += f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (violations.isNotEmpty()) {
|
|
||||||
val msg = buildString {
|
|
||||||
appendLine("Forbidden manual Authorization header usage found in:")
|
|
||||||
violations.take(50).forEach { appendLine(" - ${it.path}") }
|
|
||||||
if (violations.size > 50) appendLine(" ... and ${violations.size - 50} more files")
|
|
||||||
appendLine()
|
|
||||||
appendLine("Policy: Use DI-provided apiClient (Koin named \"apiClient\").")
|
|
||||||
}
|
|
||||||
throw GradleException(msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user