-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
authorities mapping resolver, pre-auth_code redirect handler as bean, login success and failure handlers as beans
- Loading branch information
Showing
17 changed files
with
616 additions
and
287 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 |
---|---|---|
|
@@ -21,7 +21,7 @@ logging: | |
level: | ||
org: | ||
springframework: | ||
security: DEBUG | ||
security: INFO | ||
|
||
--- | ||
server: | ||
|
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 |
---|---|---|
|
@@ -108,7 +108,8 @@ logging: | |
level: | ||
org: | ||
springframework: | ||
security: TRACE | ||
security: INFO | ||
boot: DEBUG | ||
|
||
--- | ||
spring: | ||
|
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,7 +30,7 @@ logging: | |
org: | ||
springframework: | ||
boot: INFO | ||
security: DEBUG | ||
security: INFO | ||
|
||
--- | ||
server: | ||
|
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
9 changes: 9 additions & 0 deletions
9
.../com/c4_soft/springaddons/security/oidc/starter/AuthoritiesMappingPropertiesResolver.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,9 @@ | ||
package com.c4_soft.springaddons.security.oidc.starter; | ||
|
||
import java.util.Map; | ||
|
||
import com.c4_soft.springaddons.security.oidc.starter.properties.SimpleAuthoritiesMappingProperties; | ||
|
||
public interface AuthoritiesMappingPropertiesResolver { | ||
SimpleAuthoritiesMappingProperties[] resolve(Map<String, Object> claimSet); | ||
} |
22 changes: 22 additions & 0 deletions
22
...soft/springaddons/security/oidc/starter/ByIssuerAuthoritiesMappingPropertiesResolver.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,22 @@ | ||
package com.c4_soft.springaddons.security.oidc.starter; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import org.springframework.security.oauth2.jwt.JwtClaimNames; | ||
|
||
import com.c4_soft.springaddons.security.oidc.starter.properties.SimpleAuthoritiesMappingProperties; | ||
import com.c4_soft.springaddons.security.oidc.starter.properties.SpringAddonsOidcProperties; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class ByIssuerAuthoritiesMappingPropertiesResolver implements AuthoritiesMappingPropertiesResolver{ | ||
private final SpringAddonsOidcProperties properties; | ||
|
||
@Override | ||
public SimpleAuthoritiesMappingProperties[] resolve(Map<String, Object> claimSet) { | ||
final var iss = Optional.ofNullable(claimSet.get(JwtClaimNames.ISS)).orElse(null); | ||
return properties.getOpProperties(iss).getAuthorities(); | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...ecurity/oidc/starter/properties/condition/bean/AuthenticationFailureHandlerCondition.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,50 @@ | ||
package com.c4_soft.springaddons.security.oidc.starter.properties.condition.bean; | ||
|
||
import org.springframework.boot.autoconfigure.condition.AllNestedConditions; | ||
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.security.web.authentication.AuthenticationFailureHandler; | ||
import org.springframework.security.web.server.authentication.ServerAuthenticationFailureHandler; | ||
|
||
public class AuthenticationFailureHandlerCondition extends AllNestedConditions { | ||
|
||
public AuthenticationFailureHandlerCondition() { | ||
super(ConfigurationPhase.REGISTER_BEAN); | ||
} | ||
|
||
@Conditional(NoAuthenticationFailureHandlerCondition.class) | ||
static class AuthenticationFailureHandlerMissingCondition {} | ||
|
||
@Conditional(PostLoginRedirectUriCondition.class) | ||
static class PostLoginRedirectUriProvidedCondition {} | ||
|
||
static class NoAuthenticationFailureHandlerCondition extends NoneNestedConditions { | ||
|
||
public NoAuthenticationFailureHandlerCondition() { | ||
super(ConfigurationPhase.REGISTER_BEAN); | ||
} | ||
|
||
@ConditionalOnBean(AuthenticationFailureHandler.class) | ||
static class AuthenticationFailureHandlerProvidedCondition {} | ||
|
||
@ConditionalOnBean(ServerAuthenticationFailureHandler.class) | ||
static class ServerAuthenticationFailureHandlerProvidedCondition {} | ||
} | ||
|
||
static class PostLoginRedirectUriCondition extends AnyNestedCondition { | ||
|
||
public PostLoginRedirectUriCondition() { | ||
super(ConfigurationPhase.REGISTER_BEAN); | ||
} | ||
|
||
@ConditionalOnProperty(name = "com.c4-soft.springaddons.oidc.client.post-login-redirect-host") | ||
static class PostLoginRedirectHostCondition {} | ||
|
||
@ConditionalOnProperty(name = "com.c4-soft.springaddons.oidc.client.post-login-redirect-path") | ||
static class PostLoginRedirectPathCondition {} | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...ecurity/oidc/starter/properties/condition/bean/AuthenticationSuccessHandlerCondition.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,49 @@ | ||
package com.c4_soft.springaddons.security.oidc.starter.properties.condition.bean; | ||
|
||
import org.springframework.boot.autoconfigure.condition.AllNestedConditions; | ||
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler; | ||
import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler; | ||
|
||
public class AuthenticationSuccessHandlerCondition extends AllNestedConditions { | ||
|
||
public AuthenticationSuccessHandlerCondition() { | ||
super(ConfigurationPhase.REGISTER_BEAN); | ||
} | ||
|
||
@Conditional(NoAuthenticationSuccessHandlerCondition.class) | ||
static class AuthenticationSuccessHandlerMissingCondition {} | ||
|
||
@Conditional(PostLoginRedirectUriCondition.class) | ||
static class PostLoginRedirectUriProvidedCondition {} | ||
|
||
static class NoAuthenticationSuccessHandlerCondition extends NoneNestedConditions { | ||
|
||
public NoAuthenticationSuccessHandlerCondition() { | ||
super(ConfigurationPhase.REGISTER_BEAN); | ||
} | ||
|
||
@ConditionalOnBean(AuthenticationSuccessHandler.class) | ||
static class AuthenticationSuccessHandlerProvidedCondition {} | ||
|
||
@ConditionalOnBean(ServerAuthenticationSuccessHandler.class) | ||
static class ServerAuthenticationSuccessHandlerProvidedCondition {} | ||
} | ||
|
||
static class PostLoginRedirectUriCondition extends AnyNestedCondition { | ||
|
||
public PostLoginRedirectUriCondition() { | ||
super(ConfigurationPhase.REGISTER_BEAN); | ||
} | ||
|
||
@ConditionalOnProperty(name = "com.c4-soft.springaddons.oidc.client.post-login-redirect-host") | ||
static class PostLoginRedirectHostCondition {} | ||
|
||
@ConditionalOnProperty(name = "com.c4-soft.springaddons.oidc.client.post-login-redirect-path") | ||
static class PostLoginRedirectPathCondition {} | ||
} | ||
} |
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.