forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
23 changed files
with
723 additions
and
588 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-in-docker | ||
{ | ||
"name": "Halo Dev Container", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/base:bullseye", | ||
|
||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
"version": "20.10", | ||
"enableNonRootDocker": "true", | ||
"moby": "true" | ||
}, | ||
"ghcr.io/devcontainers/features/java:1": { | ||
"version": "17", | ||
"jdkDistro": "tem" | ||
}, | ||
"ghcr.io/devcontainers/features/node:1": { | ||
"version": "20" | ||
}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"Vue.volar", | ||
"vscodevim.vim", | ||
"shengchen.vscode-checkstyle", | ||
"streetsidesoftware.code-spell-checker", | ||
"vscjava.vscode-gradle", | ||
"vmware.vscode-boot-dev-pack", | ||
"vscjava.vscode-java-pack", | ||
"bradlc.vscode-tailwindcss" | ||
] | ||
} | ||
} | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "docker --version", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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,12 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for more information: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
# https://containers.dev/guide/dependabot | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "devcontainers" | ||
directory: "/" | ||
schedule: | ||
interval: weekly |
14 changes: 14 additions & 0 deletions
14
api/src/main/java/run/halo/app/security/AfterSecurityWebFilter.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,14 @@ | ||
package run.halo.app.security; | ||
|
||
import org.pf4j.ExtensionPoint; | ||
import org.springframework.web.server.WebFilter; | ||
|
||
/** | ||
* Security web filter for after security. | ||
* | ||
* @author johnniang | ||
* @since 2.18 | ||
*/ | ||
public interface AfterSecurityWebFilter extends WebFilter, ExtensionPoint { | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
api/src/main/java/run/halo/app/security/BeforeSecurityWebFilter.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,14 @@ | ||
package run.halo.app.security; | ||
|
||
import org.pf4j.ExtensionPoint; | ||
import org.springframework.web.server.WebFilter; | ||
|
||
/** | ||
* Security web filter for before security. | ||
* | ||
* @author johnniang | ||
* @since 2.18 | ||
*/ | ||
public interface BeforeSecurityWebFilter extends WebFilter, ExtensionPoint { | ||
|
||
} |
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
36 changes: 0 additions & 36 deletions
36
.../java/run/halo/app/security/authentication/rememberme/RememberMeAuthenticationFilter.java
This file was deleted.
Oops, something went wrong.
27 changes: 20 additions & 7 deletions
27
...n/src/main/java/run/halo/app/security/authentication/rememberme/RememberMeConfigurer.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 |
---|---|---|
@@ -1,28 +1,41 @@ | ||
package run.halo.app.security.authentication.rememberme; | ||
|
||
import static org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher.MatchResult; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.config.web.server.SecurityWebFiltersOrder; | ||
import org.springframework.security.config.web.server.ServerHttpSecurity; | ||
import org.springframework.security.core.context.ReactiveSecurityContextHolder; | ||
import org.springframework.security.web.server.authentication.AuthenticationWebFilter; | ||
import org.springframework.security.web.server.context.ServerSecurityContextRepository; | ||
import org.springframework.stereotype.Component; | ||
import run.halo.app.security.authentication.SecurityConfigurer; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class RememberMeConfigurer implements SecurityConfigurer { | ||
|
||
private final RememberMeServices rememberMeServices; | ||
|
||
private final ServerSecurityContextRepository securityContextRepository; | ||
|
||
private final CookieSignatureKeyResolver cookieSignatureKeyResolver; | ||
|
||
@Override | ||
public void configure(ServerHttpSecurity http) { | ||
http.addFilterAt( | ||
new RememberMeAuthenticationFilter(securityContextRepository, | ||
rememberMeServices, authenticationManager()), | ||
SecurityWebFiltersOrder.AUTHENTICATION); | ||
var authManager = new RememberMeAuthenticationManager(cookieSignatureKeyResolver); | ||
var filter = new AuthenticationWebFilter(authManager); | ||
filter.setSecurityContextRepository(securityContextRepository); | ||
filter.setAuthenticationFailureHandler( | ||
(exchange, exception) -> rememberMeServices.loginFail(exchange.getExchange()) | ||
); | ||
filter.setServerAuthenticationConverter(rememberMeServices::autoLogin); | ||
filter.setRequiresAuthenticationMatcher( | ||
exchange -> ReactiveSecurityContextHolder.getContext() | ||
.flatMap(securityContext -> MatchResult.notMatch()) | ||
.switchIfEmpty(MatchResult.match()) | ||
); | ||
http.addFilterAt(filter, SecurityWebFiltersOrder.AUTHENTICATION); | ||
} | ||
|
||
RememberMeAuthenticationManager authenticationManager() { | ||
return new RememberMeAuthenticationManager(cookieSignatureKeyResolver); | ||
} | ||
} |
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
Oops, something went wrong.