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
391cae85
Commit
391cae85
authored
Mar 12, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy auth stub
parent
36b7c99f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
UtilResource.java
service/src/main/java/resources/UtilResource.java
+15
-0
loginController.js
...esources/assets/statics/js/controllers/loginController.js
+9
-5
main.js
service/src/main/resources/assets/statics/js/main.js
+4
-3
No files found.
service/src/main/java/resources/UtilResource.java
View file @
391cae85
...
@@ -11,7 +11,9 @@ import javax.inject.Singleton;
...
@@ -11,7 +11,9 @@ import javax.inject.Singleton;
import
javax.ws.rs.GET
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.HttpHeaders
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.util.Optional
;
import
java.util.Optional
;
@Singleton
@Singleton
...
@@ -41,4 +43,17 @@ public class UtilResource
...
@@ -41,4 +43,17 @@ public class UtilResource
}
}
return
responseBuilder
.
build
();
return
responseBuilder
.
build
();
}
}
//todo: cleanup
@GET
@Path
(
"/auth"
)
public
Response
auth
(
@Auth
User
user
)
{
String
jsRedirect
=
"<script type=\"text/javascript\">\n"
+
"<!--\n"
+
"window.location = \"/page/#/tasks\"\n"
+
"//-->\n"
+
"</script>"
;
return
Response
.
ok
().
entity
(
jsRedirect
).
header
(
HttpHeaders
.
CONTENT_TYPE
,
"text/html"
).
build
();
}
}
}
service/src/main/resources/assets/statics/js/controllers/loginController.js
View file @
391cae85
(
function
(){
(
function
(){
angular
.
module
(
'ctfApp'
).
controller
(
'LoginController'
,
angular
.
module
(
'ctfApp'
).
controller
(
'LoginController'
,
[
'$scope'
,
'$rootScope'
,
'$location'
,
'AuthenticationService'
,
[
'$scope'
,
'$rootScope'
,
'$location'
,
'AuthenticationService'
,
'$window'
,
function
(
$scope
,
$rootScope
,
$location
,
AuthenticationService
)
{
function
(
$scope
,
$rootScope
,
$location
,
AuthenticationService
,
$window
)
{
// reset login status
// reset login status
AuthenticationService
.
clearCredentials
();
AuthenticationService
.
clearCredentials
();
...
@@ -9,9 +9,13 @@
...
@@ -9,9 +9,13 @@
$scope
.
dataLoading
=
true
;
$scope
.
dataLoading
=
true
;
AuthenticationService
.
login
(
$scope
.
username
,
$scope
.
password
,
function
(
response
)
{
AuthenticationService
.
login
(
$scope
.
username
,
$scope
.
password
,
function
(
response
)
{
if
(
response
.
status
==
200
)
{
if
(
response
.
status
==
200
)
{
AuthenticationService
.
setCredentials
(
$scope
.
username
,
$scope
.
password
,
response
.
team
);
//todo: put credentials here
$
(
'.title'
).
html
(
$scope
.
username
+
'@<b>capture-the-flAGH-2016</b>:~$'
);
$window
.
location
.
href
=
"http://gpietrus1:gpietrus@localhost:8080/api/v1/auth"
;
$location
.
path
(
'/'
);
//todo: commeneted temporarily
// $window.location.href = "http://gpietrus1:gpietrus@localhost:8080/api/v1/auth";
// AuthenticationService.setCredentials($scope.username, $scope.password, response.team);
// $('.title').html($scope.username+'@<b>capture-the-flAGH-2016</b>:~$');
// $location.path('/');
}
else
{
}
else
{
$scope
.
error
=
response
.
message
;
$scope
.
error
=
response
.
message
;
$scope
.
dataLoading
=
false
;
$scope
.
dataLoading
=
false
;
...
...
service/src/main/resources/assets/statics/js/main.js
View file @
391cae85
...
@@ -85,9 +85,10 @@
...
@@ -85,9 +85,10 @@
$rootScope
.
$on
(
'$locationChangeStart'
,
function
(
event
,
next
,
current
)
{
$rootScope
.
$on
(
'$locationChangeStart'
,
function
(
event
,
next
,
current
)
{
// redirect to login page if not logged in
// redirect to login page if not logged in
console
.
log
(
'Globale'
,
$rootScope
.
globals
);
console
.
log
(
'Globale'
,
$rootScope
.
globals
);
if
(
$location
.
path
()
!==
'/login'
&&
!
$rootScope
.
globals
.
currentUser
)
{
//todo: commented temporarily
$location
.
path
(
'/login'
);
// if ($location.path() !== '/login' && !$rootScope.globals.currentUser) {
}
// $location.path('/login');
// }
});
});
}]);
}]);
...
...
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