migration: Add migration options at application.conf
To migrate, following options are required at application.conf application.conf ---- github.allow.migration = false github.client.id = "TYPE YOUR GITHUB CILENT ID" github.client.secret = "TYPE YOUR GITHUB CILENT SECRET"
@20cf619a219b18c1054324403148342e58d46368
--- app/controllers/MigrationApp.java
+++ app/controllers/MigrationApp.java
... | ... | @@ -15,11 +15,14 @@ |
15 | 15 |
import models.enumeration.ResourceType; |
16 | 16 |
import models.support.IssueLabelAggregate; |
17 | 17 |
import org.apache.commons.lang.StringUtils; |
18 |
+import play.Configuration; |
|
19 |
+import play.i18n.Messages; |
|
18 | 20 |
import play.libs.F; |
19 | 21 |
import play.libs.F.Promise; |
20 | 22 |
import play.libs.Json; |
21 | 23 |
import play.libs.ws.WS; |
22 | 24 |
import play.mvc.Result; |
25 |
+import utils.ErrorViews; |
|
23 | 26 |
import views.html.migration.home; |
24 | 27 |
|
25 | 28 |
import javax.validation.constraints.NotNull; |
... | ... | @@ -34,6 +37,7 @@ |
34 | 37 |
|
35 | 38 |
import static play.libs.Json.toJson; |
36 | 39 |
import static play.mvc.Http.Context.Implicit.request; |
40 |
+import static play.mvc.Results.forbidden; |
|
37 | 41 |
import static play.mvc.Results.ok; |
38 | 42 |
|
39 | 43 |
@AnonymousCheck |
... | ... | @@ -43,8 +47,13 @@ |
43 | 47 |
private static final String YONA_SERVER = "/"; |
44 | 48 |
|
45 | 49 |
|
50 |
+ |
|
46 | 51 |
@AnonymousCheck(requiresLogin = true, displaysFlashMessage = true) |
47 | 52 |
public static Promise<Result> migration() { |
53 |
+ final boolean isAllowed = Configuration.root().getBoolean("github.allow.migration", false); |
|
54 |
+ if(!isAllowed){ |
|
55 |
+ return Promise.pure(forbidden(ErrorViews.Forbidden.render("error.forbidden.or.not.allowed"))); |
|
56 |
+ } |
|
48 | 57 |
String authProcessingCode = request().getQueryString("code"); |
49 | 58 |
|
50 | 59 |
if(StringUtils.isNotBlank(authProcessingCode)){ |
... | ... | @@ -57,9 +66,9 @@ |
57 | 66 |
} |
58 | 67 |
|
59 | 68 |
private static Promise<String> getOAuthToken(String code) { |
60 |
- final String CLIENT_ID = "e7f9ad76a3a4ba19b2a5"; |
|
61 |
- final String CLIENT_SECRET = "32e7fb33ee5c42501cb2aac9a6f6c485bf285cf5"; |
|
62 | 69 |
final String ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token"; |
70 |
+ final String CLIENT_ID = Configuration.root().getString("github.client.id"); |
|
71 |
+ final String CLIENT_SECRET = Configuration.root().getString("github.client.secret"); |
|
63 | 72 |
|
64 | 73 |
return WS.url(ACCESS_TOKEN_URL) |
65 | 74 |
.setContentType("application/x-www-form-urlencoded") |
--- conf/application.conf.default
+++ conf/application.conf.default
... | ... | @@ -242,3 +242,12 @@ |
242 | 242 |
|
243 | 243 |
# Display private repositories in the list |
244 | 244 |
application.displayPrivateRepositories = false |
245 |
+ |
|
246 |
+ |
|
247 |
+# Github Migration |
|
248 |
+# ~~~~~~~~~~~~~~~~~ |
|
249 |
+# User can migrate their own projects to github |
|
250 |
+# |
|
251 |
+github.allow.migration = false |
|
252 |
+github.client.id = "TYPE YOUR GITHUB CILENT ID" |
|
253 |
+github.client.secret = "TYPE YOUR GITHUB CILENT SECRET"(No newline at end of file) |
--- conf/messages
+++ conf/messages
... | ... | @@ -194,6 +194,7 @@ |
194 | 194 |
error.failedTo = Failed to {0}<br>({1} {2}) |
195 | 195 |
error.forbidden = You are not authorized |
196 | 196 |
error.forbidden.or.notfound = Project not exists or unauthorized user |
197 |
+error.forbidden.or.not.allowed = Forbidden or not allowed request |
|
197 | 198 |
error.timeout = Your request could not be processed because of server timeout |
198 | 199 |
error.internalServerError = Server error has occurred; service is not available |
199 | 200 |
error.notfound = Page not found |
--- conf/messages.ko-KR
+++ conf/messages.ko-KR
... | ... | @@ -194,6 +194,7 @@ |
194 | 194 |
error.failedTo = {0}에 실패했습니다.<br>({1} {2}) |
195 | 195 |
error.forbidden = 권한이 없습니다 |
196 | 196 |
error.forbidden.or.notfound = 권한이 없거나 존재하지 않는 프로젝트입니다. |
197 |
+error.forbidden.or.not.allowed = 권한이 없거나 허용하지 않는 요청입니다. |
|
197 | 198 |
error.timeout = 요청 처리가 너무 오래 걸려 중단되었습니다 |
198 | 199 |
error.internalServerError = 서버 오류가 발생하여 서비스를 이용할 수 없습니다 |
199 | 200 |
error.notfound = 페이지를 찾을 수 없습니다 |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?