-
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.
화이트리스트 접근 시 슬랙 알림 전송 로직 작성 완료 (#398)
- Loading branch information
Showing
7 changed files
with
103 additions
and
67 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
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 was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/main/java/page/clab/api/global/util/WhitelistUtil.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,51 @@ | ||
package page.clab.api.global.util; | ||
|
||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import page.clab.api.global.config.WhitelistPatternsProperties; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
@Component | ||
public class WhitelistUtil implements InitializingBean { | ||
|
||
private static String[] swaggerPatterns; | ||
private static String[] actuatorPatterns; | ||
private static String[] whitelistPatterns; | ||
|
||
@Autowired | ||
private WhitelistPatternsProperties whitelistPatternsProperties; | ||
|
||
@Override | ||
public void afterPropertiesSet() throws Exception { | ||
swaggerPatterns = whitelistPatternsProperties.getApiDocs(); | ||
actuatorPatterns = whitelistPatternsProperties.getActuator(); | ||
whitelistPatterns = whitelistPatternsProperties.getWhitelistPatterns(); | ||
} | ||
|
||
public static boolean isSwaggerRequest(String path) { | ||
return isPatternMatch(path, swaggerPatterns); | ||
} | ||
|
||
public static boolean isActuatorRequest(String path) { | ||
return isPatternMatch(path, actuatorPatterns); | ||
} | ||
|
||
public static boolean isWhitelistRequest(String path) { | ||
return isPatternMatch(path, whitelistPatterns); | ||
} | ||
|
||
public static boolean isSwaggerIndexEndpoint(String path) { | ||
return swaggerPatterns[2].equals(path); | ||
} | ||
|
||
private static boolean isPatternMatch(String path, String[] patterns) { | ||
for (String pattern : patterns) { | ||
if (Pattern.compile(pattern).matcher(path).find()) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |