-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[BE/FEAT] 슬랙Oauth를 이용한 인증/인가 구현
- Loading branch information
Showing
96 changed files
with
2,018 additions
and
132 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
14 changes: 0 additions & 14 deletions
14
BE/eeos/resources/local-develop-environment/mysql-init.d/02_add.data.sql
This file was deleted.
Oops, something went wrong.
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
20 changes: 20 additions & 0 deletions
20
...ava/com/blackcompany/eeos/attend/application/exception/NotFoundAttendStatusException.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,20 @@ | ||
package com.blackcompany.eeos.attend.application.exception; | ||
|
||
import com.blackcompany.eeos.common.exception.BusinessException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
/** 존재하지 않는 참석 상태일 때 발생하는 예외 */ | ||
public class NotFoundAttendStatusException extends BusinessException { | ||
private static final String FAIL_CODE = "2000"; | ||
private final String attendStatus; | ||
|
||
public NotFoundAttendStatusException(String attendStatus) { | ||
super(FAIL_CODE, HttpStatus.NOT_FOUND); | ||
this.attendStatus = attendStatus; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return String.format("%s 참석 상태는 존재하지 않습니다.", attendStatus); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
...main/java/com/blackcompany/eeos/attend/application/exception/NotFoundStatusException.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...om/blackcompany/eeos/attend/application/exception/NotSameBeforeAttendStatusException.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,20 @@ | ||
package com.blackcompany.eeos.attend.application.exception; | ||
|
||
import com.blackcompany.eeos.common.exception.BusinessException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
/** 이전 참석상태가 일치하지 않을 때 발생하는 예외 */ | ||
public class NotSameBeforeAttendStatusException extends BusinessException { | ||
private static final String FAIL_CODE = "2001"; | ||
private final Long memberId; | ||
|
||
public NotSameBeforeAttendStatusException(Long memberId) { | ||
super(FAIL_CODE, HttpStatus.NOT_FOUND); | ||
this.memberId = memberId; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return String.format("%s 회원의 이전 상태가 올바르지 않습니다.", memberId); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
...java/com/blackcompany/eeos/attend/application/exception/NotSameBeforeStatusException.java
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/OauthMemberModel.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,19 @@ | ||
package com.blackcompany.eeos.auth.application.domain; | ||
|
||
import com.blackcompany.eeos.common.support.AbstractModel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class OauthMemberModel implements AbstractModel { | ||
private String oauthId; | ||
private String name; | ||
private OauthServerType oauthServerType; | ||
} |
30 changes: 30 additions & 0 deletions
30
BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/OauthServerType.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,30 @@ | ||
package com.blackcompany.eeos.auth.application.domain; | ||
|
||
import com.blackcompany.eeos.auth.application.exception.NotFoundOauthServerException; | ||
import java.util.Arrays; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum OauthServerType { | ||
SLACK("slack"); | ||
|
||
private final String oauthServer; | ||
|
||
OauthServerType(String oauthServer) { | ||
this.oauthServer = oauthServer; | ||
} | ||
|
||
public static OauthServerType find(String type) { | ||
return Arrays.stream(values()) | ||
.filter(oauthServerType -> oauthServerType.oauthServer.equals(type)) | ||
.findAny() | ||
.orElseThrow(() -> new NotFoundOauthServerException(type)); | ||
} | ||
|
||
public static OauthServerType find(OauthServerType type) { | ||
return Arrays.stream(values()) | ||
.filter(oauthServerType -> oauthServerType.equals(type)) | ||
.findAny() | ||
.orElseThrow(() -> new NotFoundOauthServerException(type.getOauthServer())); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/TokenModel.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,18 @@ | ||
package com.blackcompany.eeos.auth.application.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class TokenModel { | ||
|
||
private String accessToken; | ||
private Long accessExpiredTime; | ||
private String refreshToken; | ||
private Long refreshExpiredTime; | ||
} |
10 changes: 10 additions & 0 deletions
10
...src/main/java/com/blackcompany/eeos/auth/application/domain/client/OauthMemberClient.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.blackcompany.eeos.auth.application.domain.client; | ||
|
||
import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; | ||
import com.blackcompany.eeos.auth.application.domain.OauthServerType; | ||
|
||
public interface OauthMemberClient { | ||
OauthServerType support(); | ||
|
||
OauthMemberModel fetch(String code); | ||
} |
30 changes: 30 additions & 0 deletions
30
...java/com/blackcompany/eeos/auth/application/domain/client/OauthMemberClientComposite.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,30 @@ | ||
package com.blackcompany.eeos.auth.application.domain.client; | ||
|
||
import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; | ||
import com.blackcompany.eeos.auth.application.domain.OauthServerType; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class OauthMemberClientComposite { | ||
|
||
private final Map<OauthServerType, OauthMemberClient> clients; | ||
|
||
public OauthMemberClientComposite(Set<OauthMemberClient> providers) { | ||
this.clients = | ||
providers.stream() | ||
.collect(Collectors.toMap(OauthMemberClient::support, Function.identity())); | ||
} | ||
|
||
public OauthMemberModel fetch(String oauthServerType, String authCode) { | ||
return getClient(oauthServerType).fetch(authCode); | ||
} | ||
|
||
private OauthMemberClient getClient(String type) { | ||
OauthServerType oauthServerType = OauthServerType.find(type); | ||
return clients.get(oauthServerType); | ||
} | ||
} |
Oops, something went wrong.