Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
conifercone committed Jun 13, 2024
2 parents f5cebf6 + fdb5023 commit 764c252
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 68 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- v1.0.1 Unique data generation service adds code generation function.
- v1.0.1 Account registration adds email verification.
- v1.0.1 Add email notification for account deletion.
- v1.0.1 Improve log burying points.

### Changed

### Removed

## [1.0.0] - 2024-06-13

### Added

- Authentication server.
- Resource Server Client.
- Operation log collection function.
- System log collection function.
- Distributed unique primary key generation.
- Distributed lock based on zookeeper.

[unreleased]: https://github.com/conifercone/centaur/compare/v1.0.0...develop

[1.0.0]: https://github.com/conifercone/centaur/releases/tag/v1.0.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
![GitHub repo size](https://img.shields.io/github/repo-size/conifercone/centaur)
![GitHub top language](https://img.shields.io/github/languages/top/conifercone/centaur)
[![JDK version](https://img.shields.io/badge/JDK-21+-green.svg)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
[![centaur version](https://img.shields.io/badge/centaur-1.0.0--SNAPSHOT-brightgreen)](https://github.com/conifercone/centaur)
![GitHub Release](https://img.shields.io/github/v/release/conifercone/centaur)
[![GitHub License](https://img.shields.io/github/license/conifercone/centaur)](https://github.com/conifercone/centaur)
[![GitHub issues](https://img.shields.io/github/issues/conifercone/centaur)](https://github.com/conifercone/centaur)
[![GitHub language count](https://img.shields.io/github/languages/count/conifercone/centaur)](https://github.com/conifercone/centaur)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public class AccountGrpcService extends AuthenticationGrpcService implements Dis
private static final Logger LOGGER = LoggerFactory.getLogger(AccountGrpcService.class);

public AccountGrpcService(
DiscoveryClient consulDiscoveryClient,
DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
super(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
super(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
*/
class AuthenticationGrpcService {

private final DiscoveryClient consulDiscoveryClient;
private final DiscoveryClient discoveryClient;

private final ObservationGrpcClientInterceptor observationGrpcClientInterceptor;

public AuthenticationGrpcService(DiscoveryClient consulDiscoveryClient,
public AuthenticationGrpcService(DiscoveryClient discoveryClient,
@NotNull ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
this.consulDiscoveryClient = consulDiscoveryClient;
this.discoveryClient = discoveryClient;
this.observationGrpcClientInterceptor = grpcClientInterceptorObjectProvider.getIfAvailable();
}

Expand All @@ -57,7 +57,7 @@ protected Optional<ManagedChannel> getManagedChannelUsePlaintext() {
}

protected Optional<ServiceInstance> getServiceInstance() {
List<ServiceInstance> instances = consulDiscoveryClient.getInstances("grpc-authentication");
List<ServiceInstance> instances = discoveryClient.getInstances("grpc-authentication");
return Optional.ofNullable(instances).flatMap(is -> is.stream().findFirst());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public class AuthorityGrpcService extends AuthenticationGrpcService implements
private static final Logger LOGGER = LoggerFactory.getLogger(AuthorityGrpcService.class);

public AuthorityGrpcService(
DiscoveryClient consulDiscoveryClient,
DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
super(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
super(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public class RoleGrpcService extends AuthenticationGrpcService implements Dispos
private static final Logger LOGGER = LoggerFactory.getLogger(RoleGrpcService.class);

public RoleGrpcService(
DiscoveryClient consulDiscoveryClient,
DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
super(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
super(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class TokenGrpcService extends AuthenticationGrpcService implements Dispo
private static final Logger LOGGER = LoggerFactory.getLogger(TokenGrpcService.class);

public TokenGrpcService(
DiscoveryClient consulDiscoveryClient,
DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
super(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
super(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@
public class AuthenticationClientConfiguration {

@Bean
public TokenGrpcService tokenGrpcService(DiscoveryClient consulDiscoveryClient,
public TokenGrpcService tokenGrpcService(DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
return new TokenGrpcService(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
return new TokenGrpcService(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Bean
public AccountGrpcService accountGrpcService(DiscoveryClient consulDiscoveryClient,
public AccountGrpcService accountGrpcService(DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
return new AccountGrpcService(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
return new AccountGrpcService(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Bean
public AuthorityGrpcService authorityGrpcService(DiscoveryClient consulDiscoveryClient,
public AuthorityGrpcService authorityGrpcService(DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
return new AuthorityGrpcService(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
return new AuthorityGrpcService(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Bean
public RoleGrpcService roleGrpcService(DiscoveryClient consulDiscoveryClient,
public RoleGrpcService roleGrpcService(DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
return new RoleGrpcService(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
return new RoleGrpcService(discoveryClient, grpcClientInterceptorObjectProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Collections;
import java.util.Optional;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -108,11 +109,11 @@ public Account(Long id, String username, String password, Boolean enabled,

@Override
public Collection<Authority> getAuthorities() {
List<Authority> authorities = this.role.getAuthorities();
Authority authority = new Authority();
authority.setCode("ROLE_".concat(this.role.getCode()));
authorities.add(authority);
return authorities;
return Optional.ofNullable(this.role)
.flatMap((accountRole) -> Optional.ofNullable(accountRole.getAuthorities()))
.stream().peek(authorities -> authorities.add(
Authority.builder().code("ROLE_".concat(this.role.getCode())).build())).findAny()
.orElse(Collections.emptyList());
}

public void setAuthorities(Collection<Authority> authorities) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.sky.centaur.basis.domain.BasisDomainModel;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.springframework.security.core.GrantedAuthority;

/**
Expand All @@ -40,24 +42,17 @@
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder(toBuilder = true)
public class Authority extends BasisDomainModel implements GrantedAuthority {

@Serial
private static final long serialVersionUID = -5474154746791467326L;

private Long id;
private String code;
private String name;

/**
* all properties constructor
*/
public Authority(Long id, String code, String name) {
this.id = id;
this.code = code;
this.name = name;
}

@Override
public String getAuthority() {
return code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
import com.sky.centaur.authentication.domain.authority.Authority;
import com.sky.centaur.basis.domain.BasisDomainModel;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

/**
* 角色领域模型
Expand All @@ -40,21 +42,13 @@
@JsonDeserialize
@JsonIgnoreProperties(ignoreUnknown = true)
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder(toBuilder = true)
public class Role extends BasisDomainModel {

private Long id;
private String code;
private String name;
private List<Authority> authorities;

/**
* all properties constructor
*/
public Role(Long id, String code, String name, List<Authority> authorities) {
this.id = id;
this.code = code;
this.name = name;
this.authorities = authorities;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@
public interface AccountRepository extends BaseJpaRepository<AccountDo, Long>,
JpaSpecificationExecutor<AccountDo> {

/**
* 根据用户名查询账户
*
* @param username 用户名
* @return 账户数据对象
*/
Optional<AccountDo> findAccountDoByUsername(String username);

/**
* 根据邮箱查询账户
*
* @param email 邮箱地址
* @return 账户数据对象
*/
Optional<AccountDo> findAccountDoByEmail(String email);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,11 @@
public interface AuthorityRepository extends BaseJpaRepository<AuthorityDo, Long>,
JpaSpecificationExecutor<AuthorityDo> {

/**
* 查询所有在id集合中的权限
*
* @param ids id集合
* @return 权限数据对象集合
*/
List<AuthorityDo> findAuthorityDoByIdIn(Collection<Long> ids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@
public interface RoleRepository extends BaseJpaRepository<RoleDo, Long>,
JpaSpecificationExecutor<RoleDo> {

/**
* 根据编码查询角色
*
* @param code 角色编码
* @return 角色数据对象
*/
Optional<RoleDo> findByCode(String code);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

/**
* 基础领域模型
Expand All @@ -28,6 +30,8 @@
*/
@Getter
@Setter
@SuperBuilder(toBuilder = true)
@NoArgsConstructor
public abstract class BasisDomainModel implements DomainModel {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
public class LogClientConfiguration {

@Bean
public OperationLogGrpcService operationLogGrpcService(DiscoveryClient consulDiscoveryClient,
public OperationLogGrpcService operationLogGrpcService(DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
return new OperationLogGrpcService(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
return new OperationLogGrpcService(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Bean
public SystemLogGrpcService systemLogGrpcService(DiscoveryClient consulDiscoveryClient,
public SystemLogGrpcService systemLogGrpcService(DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
return new SystemLogGrpcService(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
return new SystemLogGrpcService(discoveryClient, grpcClientInterceptorObjectProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
*/
class LogGrpcService {

private final DiscoveryClient consulDiscoveryClient;
private final DiscoveryClient discoveryClient;

private final ObservationGrpcClientInterceptor observationGrpcClientInterceptor;

public LogGrpcService(DiscoveryClient consulDiscoveryClient,
public LogGrpcService(DiscoveryClient discoveryClient,
@NotNull ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
this.consulDiscoveryClient = consulDiscoveryClient;
this.discoveryClient = discoveryClient;
this.observationGrpcClientInterceptor = grpcClientInterceptorObjectProvider.getIfAvailable();
}

Expand All @@ -57,7 +57,7 @@ protected Optional<ManagedChannel> getManagedChannelUsePlaintext() {
}

protected Optional<ServiceInstance> getServiceInstance() {
List<ServiceInstance> instances = consulDiscoveryClient.getInstances("grpc-log");
List<ServiceInstance> instances = discoveryClient.getInstances("grpc-log");
return Optional.ofNullable(instances).flatMap(is -> is.stream().findFirst());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class OperationLogGrpcService extends LogGrpcService implements Disposabl
private ManagedChannel channel;

public OperationLogGrpcService(
DiscoveryClient consulDiscoveryClient,
DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
super(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
super(discoveryClient, grpcClientInterceptorObjectProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class SystemLogGrpcService extends LogGrpcService implements DisposableBe
private ManagedChannel channel;

public SystemLogGrpcService(
DiscoveryClient consulDiscoveryClient,
DiscoveryClient discoveryClient,
ObjectProvider<ObservationGrpcClientInterceptor> grpcClientInterceptorObjectProvider) {
super(consulDiscoveryClient, grpcClientInterceptorObjectProvider);
super(discoveryClient, grpcClientInterceptorObjectProvider);
}


Expand Down
Loading

0 comments on commit 764c252

Please sign in to comment.