-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
189 changed files
with
6,519 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ jobs: | |
PREDICTIVE_TEST_SELECTION: "${{ github.event_name == 'pull_request' && 'true' || 'false' }}" | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OSS_INDEX_USERNAME: ${{ secrets.OSS_INDEX_USERNAME }} | ||
OSS_INDEX_PASSWORD: ${{ secrets.OSS_INDEX_PASSWORD }} | ||
steps: | ||
# https://github.com/actions/virtual-environments/issues/709 | ||
- name: "🗑 Free disk space" | ||
|
@@ -45,7 +47,7 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: "🔧 Setup GraalVM CE" | ||
uses: graalvm/[email protected].3 | ||
uses: graalvm/[email protected].6 | ||
with: | ||
distribution: 'graalvm' | ||
java-version: ${{ matrix.java }} | ||
|
@@ -58,6 +60,11 @@ jobs: | |
run: | | ||
[ -f ./setup.sh ] && ./setup.sh || [ ! -f ./setup.sh ] | ||
- name: "🚔 Sonatype Scan" | ||
id: sonatypescan | ||
run: | | ||
./gradlew ossIndexAudit --no-parallel | ||
- name: "🛠 Build with Gradle" | ||
id: gradle | ||
run: | | ||
|
@@ -70,15 +77,15 @@ jobs: | |
- name: "📊 Publish Test Report" | ||
if: always() | ||
uses: mikepenz/action-junit-report@v4 | ||
uses: mikepenz/action-junit-report@v5 | ||
with: | ||
check_name: Java CI / Test Report (${{ matrix.java }}) | ||
report_paths: '**/build/test-results/test/TEST-*.xml' | ||
check_retries: 'true' | ||
|
||
- name: "📜 Upload binary compatibility check results" | ||
if: matrix.java == '17' | ||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | ||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 | ||
with: | ||
name: binary-compatibility-reports | ||
path: "**/build/reports/binary-compatibility-*.html" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
libs { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
buildSrc/src/main/groovy/io.micronaut.build.internal.security-module.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
plugins { | ||
id "io.micronaut.build.internal.security-base" | ||
id "io.micronaut.build.internal.module" | ||
id("org.sonatype.gradle.plugins.scan") | ||
} | ||
String ossIndexUsername = System.getenv("OSS_INDEX_USERNAME") ?: project.properties["ossIndexUsername"] | ||
String ossIndexPassword = System.getenv("OSS_INDEX_PASSWORD") ?: project.properties["ossIndexPassword"] | ||
boolean sonatypePluginConfigured = ossIndexUsername != null && ossIndexPassword != null | ||
if (sonatypePluginConfigured) { | ||
ossIndexAudit { | ||
username = ossIndexUsername | ||
password = ossIndexPassword | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
plugins { | ||
id("io.micronaut.build.internal.security-module") | ||
} | ||
|
||
dependencies { | ||
api(projects.micronautSecurity) | ||
compileOnly(mn.micronaut.http.server) | ||
compileOnly(projects.micronautSecuritySession) | ||
testAnnotationProcessor(mn.micronaut.inject.java) | ||
testImplementation(mnTest.micronaut.test.junit5) | ||
testRuntimeOnly(libs.junit.jupiter.engine) | ||
testRuntimeOnly(mnLogging.logback.classic) | ||
testImplementation(mn.micronaut.http.server.netty) | ||
testImplementation(mn.micronaut.http.client) | ||
testAnnotationProcessor(mnSerde.micronaut.serde.processor) | ||
testImplementation(mnSerde.micronaut.serde.jackson) | ||
testImplementation(projects.testSuiteUtilsSecurity) | ||
testImplementation(projects.micronautSecurityJwt) | ||
testImplementation(projects.micronautSecuritySession) | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
} | ||
|
||
micronautBuild { | ||
binaryCompatibility.enabled = false | ||
} |
65 changes: 65 additions & 0 deletions
65
security-csrf/src/main/java/io/micronaut/security/csrf/CsrfConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2017-2024 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.security.csrf; | ||
|
||
import io.micronaut.core.annotation.NonNull; | ||
import io.micronaut.core.annotation.Nullable; | ||
import io.micronaut.core.util.Toggleable; | ||
import io.micronaut.http.cookie.CookieConfiguration; | ||
import io.micronaut.security.config.SecurityConfigurationProperties; | ||
|
||
/** | ||
* CSRF Configuration. | ||
* @author Sergio del Amo | ||
* @since 4.11.0 | ||
*/ | ||
public interface CsrfConfiguration extends CookieConfiguration, Toggleable { | ||
String PREFIX = SecurityConfigurationProperties.PREFIX + ".csrf"; | ||
|
||
/** | ||
* | ||
* @return Random value's size in bytes. The random value used is used to build a CSRF Token. | ||
*/ | ||
int getRandomValueSize(); | ||
|
||
/** | ||
* | ||
* @return The Secret Key that is used to calculate an HMAC as part of a CSRF token generation. | ||
*/ | ||
@Nullable | ||
String getSecretKey(); | ||
|
||
/** | ||
* HTTP Header name to look for the CSRF token. It is recommended to use a custom request header. By using a custom HTTP Header name, it will not be possible to send them cross-origin without a permissive CORS implementation. | ||
* @return HTTP Header name to look for the CSRF token. | ||
*/ | ||
@NonNull | ||
String getHeaderName(); | ||
|
||
/** | ||
* | ||
* @return Key to look for the CSRF token in an HTTP Session. | ||
*/ | ||
@NonNull | ||
String getHttpSessionName(); | ||
|
||
/** | ||
* | ||
* @return Field name in a form url encoded submission to look for the CSRF token. | ||
*/ | ||
@NonNull | ||
String getFieldName(); | ||
} |
Oops, something went wrong.