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
36b7c99f
Commit
36b7c99f
authored
Mar 11, 2016
by
Antek Grzanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login logout works flawlessly!
parent
91a87295
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
17 deletions
+37
-17
CTFApplication.java
service/src/main/java/CTFApplication.java
+1
-1
apiProvider.js
service/src/main/resources/assets/statics/js/apiProvider.js
+2
-2
authenticationService.js
...main/resources/assets/statics/js/authenticationService.js
+6
-6
loginController.js
...esources/assets/statics/js/controllers/loginController.js
+1
-1
navigationController.js
...ces/assets/statics/js/controllers/navigationController.js
+1
-1
scoreboardController.js
...ces/assets/statics/js/controllers/scoreboardController.js
+1
-1
taskController.js
...resources/assets/statics/js/controllers/taskController.js
+1
-1
main.js
service/src/main/resources/assets/statics/js/main.js
+24
-4
No files found.
service/src/main/java/CTFApplication.java
View file @
36b7c99f
...
...
@@ -63,7 +63,7 @@ public class CTFApplication extends Application<ApplicationConfiguration>
.
setAuthenticator
(
injector
.
getInstance
(
ExampleAuthenticator
.
class
))
.
setAuthorizer
(
new
ExampleAuthorizer
())
.
setRealm
(
"SUPER SECRET STUFF"
)
.
setPrefix
(
"Not-So-Basic"
)
//
.setPrefix("Not-So-Basic")
.
buildAuthFilter
()));
environment
.
jersey
().
register
(
RolesAllowedDynamicFeature
.
class
);
environment
.
jersey
().
register
(
new
AuthValueFactoryProvider
.
Binder
<>(
User
.
class
));
...
...
service/src/main/resources/assets/statics/js/apiProvider.js
View file @
36b7c99f
...
...
@@ -4,7 +4,7 @@
return
{
getScores
:
function
(){},
getTasks
:
function
(
callback
){
$http
.
get
(
AppSettings
.
apiAddress
+
'/tasks'
).
$http
.
get
(
'http://'
+
AppSettings
.
apiAddress
+
'/tasks'
).
success
(
function
(
data
)
{
tasks
=
data
;
if
(
callback
)
callback
(
data
);
...
...
@@ -25,7 +25,7 @@
callback
(
result
);
},
submitFlag
:
function
(
flag
){
return
$http
.
post
(
AppSettings
.
apiAddress
+
'/solutions'
,
flag
);
return
$http
.
post
(
'http://'
+
AppSettings
.
apiAddress
+
'/solutions'
,
flag
);
}
};
}]);
...
...
service/src/main/resources/assets/statics/js/authenticationService.js
View file @
36b7c99f
...
...
@@ -13,8 +13,8 @@
*/
login
:
function
(
username
,
password
,
callback
)
{
$http
.
get
(
AppSettings
.
apiAddress
+
'/whoami'
,
{
headers
:
{
'Authorization'
:
'
Not-So-
Basic '
+
Base64
.
encode
(
username
+
':'
+
password
)}
$http
.
get
(
'http://'
+
username
+
":"
+
password
+
"@"
+
AppSettings
.
apiAddress
+
'/whoami'
,
{
headers
:
{
'Authorization'
:
'Basic '
+
Base64
.
encode
(
username
+
':'
+
password
)}
})
.
then
(
function
(
response
)
{
console
.
debug
(
"RESPONSE"
,
response
);
...
...
@@ -32,8 +32,8 @@
*/
logout
:
function
(
callback
)
{
$http
.
get
(
AppSettings
.
apiAddress
+
'/whoami'
,
{
headers
:
{
'Authorization'
:
'
Not-So-
Basic '
+
Base64
.
encode
(
'askdjfadsf'
+
':'
+
'adsfasskdjfadsf'
)}
$http
.
get
(
'http://'
+
'askdjfadsf'
+
':'
+
'adsfasskdjfadsf'
+
'@'
+
AppSettings
.
apiAddress
+
'/whoami'
,
{
headers
:
{
'Authorization'
:
'Basic '
+
Base64
.
encode
(
'askdjfadsf'
+
':'
+
'adsfasskdjfadsf'
)}
}).
then
(
function
(
response
){
this
.
clearCredentials
();
callback
(
response
);
...
...
@@ -61,7 +61,7 @@
}
};
$http
.
defaults
.
headers
.
common
[
'Authorization'
]
=
'
Not-So-
Basic '
+
authdata
;
$http
.
defaults
.
headers
.
common
[
'Authorization'
]
=
'Basic '
+
authdata
;
$cookieStore
.
put
(
'globals'
,
$rootScope
.
globals
);
},
...
...
@@ -73,7 +73,7 @@
$rootScope
.
globals
=
{};
$cookieStore
.
remove
(
'globals'
);
$http
.
defaults
.
headers
.
common
.
Authorization
=
'
Not-So-
Basic '
$http
.
defaults
.
headers
.
common
.
Authorization
=
'Basic '
}
...
...
service/src/main/resources/assets/statics/js/controllers/loginController.js
View file @
36b7c99f
...
...
@@ -10,7 +10,7 @@
AuthenticationService
.
login
(
$scope
.
username
,
$scope
.
password
,
function
(
response
)
{
if
(
response
.
status
==
200
)
{
AuthenticationService
.
setCredentials
(
$scope
.
username
,
$scope
.
password
,
response
.
team
);
$
(
'.title'
).
html
(
$scope
.
username
+
'@<b>capture-the-flAGH-2016</b>'
);
$
(
'.title'
).
html
(
$scope
.
username
+
'@<b>capture-the-flAGH-2016</b>
:~$
'
);
$location
.
path
(
'/'
);
}
else
{
$scope
.
error
=
response
.
message
;
...
...
service/src/main/resources/assets/statics/js/controllers/navigationController.js
View file @
36b7c99f
...
...
@@ -9,7 +9,7 @@
$scope
.
logout
=
function
(){
AuthenticationService
.
logout
(
function
(
data
){
console
.
log
(
"Logged you out... i guess..."
,
data
);
$
(
'.title'
).
html
(
'guest@<b>capture-the-flAGH-2016</b>'
);
$
(
'.title'
).
html
(
'guest@<b>capture-the-flAGH-2016</b>
:~$
'
);
$location
.
path
(
'/'
);
});
};
...
...
service/src/main/resources/assets/statics/js/controllers/scoreboardController.js
View file @
36b7c99f
...
...
@@ -31,7 +31,7 @@
}
$http
.
get
(
AppSettings
.
apiAddress
+
'/solutions/all'
).
$http
.
get
(
'http://'
+
AppSettings
.
apiAddress
+
'/solutions/all'
).
success
(
function
(
data
)
{
console
.
log
(
data
);
if
(
$
.
isEmptyObject
(
data
)){
...
...
service/src/main/resources/assets/statics/js/controllers/taskController.js
View file @
36b7c99f
(
function
(){
angular
.
module
(
'ctfApp'
).
controller
(
'TaskController'
,
[
'$scope'
,
'$stateParams'
,
'APIProvider'
,
'AppSettings'
,
function
(
$scope
,
$stateParams
,
APIProvider
,
AppSettings
)
{
$scope
.
submitUnknown
=
false
;
$scope
.
apiAddress
=
AppSettings
.
apiAddress
;
$scope
.
apiAddress
=
'http://'
+
AppSettings
.
apiAddress
;
$scope
.
selectedTaskId
=
$stateParams
.
taskLevel
;
console
.
log
(
'SELECTED TASK ID'
,
$scope
.
selectedTaskId
);
APIProvider
.
getTaskById
(
$scope
.
selectedTaskId
,
function
(
data
){
...
...
service/src/main/resources/assets/statics/js/main.js
View file @
36b7c99f
...
...
@@ -39,10 +39,30 @@
app
.
factory
(
'AppSettings'
,
function
()
{
return
{
apiAddress
:
"
http://
localhost:8080/api/v1"
apiAddress
:
"localhost:8080/api/v1"
}
});
app
.
config
(
function
(
$httpProvider
)
{
$httpProvider
.
interceptors
.
push
(
function
(
$q
)
{
return
{
'response'
:
function
(
response
)
{
if
(
response
.
status
===
401
)
{
console
.
log
(
"Response 401"
);
}
return
response
||
$q
.
when
(
response
);
},
'responseError'
:
function
(
rejection
)
{
if
(
rejection
.
status
===
401
)
{
console
.
log
(
"Response Error 401"
);
}
return
$q
.
reject
(
rejection
);
}
};
});
});
app
.
run
([
'$rootScope'
,
'$location'
,
'$cookieStore'
,
'$http'
,
function
(
$rootScope
,
$location
,
$cookieStore
,
$http
)
{
...
...
@@ -52,14 +72,14 @@
var
username
=
$rootScope
.
globals
.
currentUser
?
$rootScope
.
globals
.
currentUser
.
username
:
'guest'
;
$
(
".title"
).
typed
({
strings
:
[
username
+
"@<b>capture-the-flag</b>
"
,
username
+
"@<b>capture-the-flAGH-2016</b>
"
],
strings
:
[
username
+
"@<b>capture-the-flag</b>
:~$"
,
username
+
"@<b>capture-the-flAGH-2016</b>:~$
"
],
startDelay
:
10
,
backDelay
:
500
,
whenToStop
:
1
4
+
username
.
length
whenToStop
:
1
7
+
username
.
length
});
if
(
$rootScope
.
globals
.
currentUser
)
{
$http
.
defaults
.
headers
.
common
[
'Authorization'
]
=
'
Not-So-
Basic '
+
$rootScope
.
globals
.
currentUser
.
authdata
;
// jshint ignore:line
$http
.
defaults
.
headers
.
common
[
'Authorization'
]
=
'Basic '
+
$rootScope
.
globals
.
currentUser
.
authdata
;
// jshint ignore:line
}
$rootScope
.
$on
(
'$locationChangeStart'
,
function
(
event
,
next
,
current
)
{
...
...
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