Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
cad8e3d0
Commit
cad8e3d0
authored
Mar 21, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clenaup auth endpoint
parent
92fb7719
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
UtilResource.java
...m/telephoners/krakyournet/ctf/resources/UtilResource.java
+10
-8
redirect.html
service/src/main/resources/assets/redirect.html
+10
-0
No files found.
service/src/main/java/com/telephoners/krakyournet/ctf/resources/UtilResource.java
View file @
cad8e3d0
...
...
@@ -5,6 +5,7 @@ import com.telephoners.krakyournet.ctf.beans.Team;
import
com.telephoners.krakyournet.ctf.beans.User
;
import
com.telephoners.krakyournet.ctf.repositories.TeamsRepository
;
import
io.dropwizard.auth.Auth
;
import
org.apache.commons.io.FileUtils
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
...
...
@@ -14,6 +15,8 @@ import javax.ws.rs.Produces;
import
javax.ws.rs.core.HttpHeaders
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Optional
;
@Singleton
...
...
@@ -44,16 +47,15 @@ public class UtilResource
return
responseBuilder
.
build
();
}
//todo: cleanup
@GET
@Path
(
"/auth"
)
public
Response
auth
(
@Auth
User
user
)
public
Response
auth
(
@Auth
User
user
)
throws
IOException
{
String
jsRedirect
=
"<script type=\"text/javascript\">\n"
+
"<!--\n"
+
"window.location = \"http://\" + window.location.host + \"/page\"\n"
+
"//-->\n"
+
"</script>"
;
return
Response
.
ok
().
entity
(
jsRedirect
).
header
(
HttpHeaders
.
CONTENT_TYPE
,
"text/html"
).
header
(
HttpHeaders
.
WWW_AUTHENTICATE
,
"Basic"
)
.
build
();
String
redirectHtml
=
new
String
(
FileUtils
.
readFileToByteArray
(
new
File
(
"service/src/main/resources/assets/redirect.html"
)));
return
Response
.
ok
()
.
entity
(
redirectHtml
)
.
header
(
HttpHeaders
.
CONTENT_TYPE
,
"text/html"
)
.
header
(
HttpHeaders
.
WWW_AUTHENTICATE
,
"Basic"
)
.
build
();
}
}
service/src/main/resources/assets/redirect.html
0 → 100644
View file @
cad8e3d0
<!DOCTYPE html>
<html
lang=
"en"
ng-app=
"ctfApp"
>
<head>
</head>
<script
type=
"text/javascript"
>
window
.
location
=
"http://"
+
window
.
location
.
host
+
"/page"
;
</script>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment