-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
340 additions
and
216 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
10 changes: 10 additions & 0 deletions
10
...authorization/src/main/java/com/plate/authorization/config/AuthorizationServerConfig.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,10 @@ | ||
package com.plate.authorization.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author Alex bob(<a href="https://github.com/vnobo">Alex Bob</a>) | ||
*/ | ||
@Configuration | ||
public class AuthorizationServerConfig { | ||
} |
36 changes: 36 additions & 0 deletions
36
boot/authorization/src/main/java/com/plate/authorization/config/SecurityConfig.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,36 @@ | ||
package com.plate.authorization.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.security.config.Customizer; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; | ||
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; | ||
import org.springframework.security.web.util.matcher.MediaTypeRequestMatcher; | ||
|
||
/** | ||
* @author Alex bob(<a href="https://github.com/vnobo">Alex Bob</a>) | ||
*/ | ||
@Configuration | ||
public class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) | ||
throws Exception { | ||
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); | ||
http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) | ||
.oidc(Customizer.withDefaults()); | ||
http.exceptionHandling((exceptions) -> exceptions | ||
.defaultAuthenticationEntryPointFor( | ||
new LoginUrlAuthenticationEntryPoint("/login"), | ||
new MediaTypeRequestMatcher(MediaType.TEXT_HTML) | ||
) | ||
).oauth2ResourceServer((oauth2) -> oauth2.jwt(Customizer.withDefaults())); | ||
|
||
return http.cors(Customizer.withDefaults()).build(); | ||
} | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
boot/authorization/src/main/java/com/plate/authorization/core/Authorization.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,76 @@ | ||
package com.plate.authorization.core; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.time.Instant; | ||
|
||
/** | ||
* @author Alex bob(<a href="https://github.com/vnobo">Alex Bob</a>) | ||
*/ | ||
@Data | ||
@Entity | ||
@Table(name = "oauth2_authorization") | ||
public class Authorization implements Serializable { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
private String registeredClientId; | ||
private String principalName; | ||
private String authorizationGrantType; | ||
@Column(length = 1000) | ||
private String authorizedScopes; | ||
@Column(length = 4000) | ||
private String attributes; | ||
@Column(length = 500) | ||
private String state; | ||
|
||
@Column(length = 4000) | ||
private String authorizationCodeValue; | ||
private Instant authorizationCodeIssuedAt; | ||
private Instant authorizationCodeExpiresAt; | ||
private String authorizationCodeMetadata; | ||
|
||
@Column(length = 4000) | ||
private String accessTokenValue; | ||
private Instant accessTokenIssuedAt; | ||
private Instant accessTokenExpiresAt; | ||
@Column(length = 2000) | ||
private String accessTokenMetadata; | ||
private String accessTokenType; | ||
@Column(length = 1000) | ||
private String accessTokenScopes; | ||
|
||
@Column(length = 4000) | ||
private String refreshTokenValue; | ||
private Instant refreshTokenIssuedAt; | ||
private Instant refreshTokenExpiresAt; | ||
@Column(length = 2000) | ||
private String refreshTokenMetadata; | ||
|
||
@Column(length = 4000) | ||
private String oidcIdTokenValue; | ||
private Instant oidcIdTokenIssuedAt; | ||
private Instant oidcIdTokenExpiresAt; | ||
@Column(length = 2000) | ||
private String oidcIdTokenMetadata; | ||
@Column(length = 2000) | ||
private String oidcIdTokenClaims; | ||
|
||
@Column(length = 4000) | ||
private String userCodeValue; | ||
private Instant userCodeIssuedAt; | ||
private Instant userCodeExpiresAt; | ||
@Column(length = 2000) | ||
private String userCodeMetadata; | ||
|
||
@Column(length = 4000) | ||
private String deviceCodeValue; | ||
private Instant deviceCodeIssuedAt; | ||
private Instant deviceCodeExpiresAt; | ||
@Column(length = 2000) | ||
private String deviceCodeMetadata; | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
boot/authorization/src/main/java/com/plate/authorization/core/AuthorizationConsent.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,24 @@ | ||
package com.plate.authorization.core; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* @author Alex bob(<a href="https://github.com/vnobo">Alex Bob</a>) | ||
*/ | ||
@Data | ||
@Entity | ||
@Table(name = "oauth2_authorization_consent") | ||
public class AuthorizationConsent implements Serializable{ | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
|
||
private String registeredClientId; | ||
private String principalName; | ||
@Column(length = 1000) | ||
private String authorities; | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
boot/authorization/src/main/java/com/plate/authorization/core/Client.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,52 @@ | ||
package com.plate.authorization.core; | ||
|
||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.time.Instant; | ||
|
||
/** | ||
* @author Alex bob(<a href="https://github.com/vnobo">Alex Bob</a>) | ||
*/ | ||
@Data | ||
@Entity | ||
@Table(name = "oauth2_client") | ||
public class Client implements Serializable { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
|
||
private String clientId; | ||
|
||
private Instant clientIdIssuedAt; | ||
|
||
private String clientSecret; | ||
|
||
private Instant clientSecretExpiresAt; | ||
|
||
private String clientName; | ||
|
||
@Column(length = 1000) | ||
private String clientAuthenticationMethods; | ||
|
||
@Column(length = 1000) | ||
private String authorizationGrantTypes; | ||
|
||
@Column(length = 1000) | ||
private String redirectUris; | ||
|
||
@Column(length = 1000) | ||
private String postLogoutRedirectUris; | ||
|
||
@Column(length = 1000) | ||
private String scopes; | ||
|
||
@Column(length = 2000) | ||
private String clientSettings; | ||
|
||
@Column(length = 2000) | ||
private String tokenSettings; | ||
} |
22 changes: 22 additions & 0 deletions
22
boot/authorization/src/main/resources/application-local.yml
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 @@ | ||
logging: | ||
register-shutdown-hook: true | ||
level: | ||
web: debug | ||
com.platform.boot.*: debug | ||
org.springframework.jdbc: DEBUG | ||
|
||
server.port: 9000 | ||
|
||
spring: | ||
application.name: plate | ||
sql.init: | ||
mode: always | ||
platform: postgres | ||
encoding: utf-8 | ||
datasource: | ||
url: jdbc:postgresql://192.168.1.2:5432/plate?fetchSize=2000 | ||
username: farmer | ||
password: q1w2e3.. | ||
data.redis: | ||
host: 192.168.1.2 | ||
repositories.enabled: false |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.