diff --git a/README.md b/README.md
index 36a06ba..720f5c9 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@ now with xssbook you can run as much stallman disapprovement as you want
- all inputs on the site are unfiltered
- api calls dont care what you send them as long as they are valid strings
- /console page to see everyones amazing api calls
+- /admin page for adnim things
**installation**
@@ -17,6 +18,8 @@ The project is written in rust, so you can build it by running
Next, make sure where you are runing the binary from, that you copy the sources public folder to the same directory. The public folder is needed to server html, css, js, and font files.
+Next, the /admin page is protected by a set secret. By default this is set to admin, but you should change it by setting the `SECRET` environment variable.
+
Finally, the site runs on port `8080`, so its recommended you put it behind a reverse proxy, or you could use a docker container and remap the outsite port (see below).
**docker**
diff --git a/deployments/docker/docker-compose.yml b/deployments/docker/docker-compose.yml
index e58c9f6..09415e4 100644
--- a/deployments/docker/docker-compose.yml
+++ b/deployments/docker/docker-compose.yml
@@ -4,6 +4,8 @@ services:
ritlug-discord-bot:
container_name: xssbook
image: xssbook
+ environment:
+ - SECRET="admin"
ports:
- 8080:8080
volumes:
diff --git a/public/admin.html b/public/admin.html
new file mode 100644
index 0000000..fe8e38b
--- /dev/null
+++ b/public/admin.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+ XSSBook - Admin Panel
+
+
+
+
+
+
+ Admin Login
+
+
+
+
+
+ Submit
+ View Posts
+ View Users
+ View Sessions
+
+
+
+
\ No newline at end of file
diff --git a/public/css/admin.css b/public/css/admin.css
new file mode 100644
index 0000000..1b6e2ac
--- /dev/null
+++ b/public/css/admin.css
@@ -0,0 +1,133 @@
+body {
+ margin: 0;
+ padding: 0;
+ background-color: #181818;
+}
+
+#header {
+ background-color: #242424;
+}
+
+#login {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 100vw;
+ height: 100vh;
+ flex-direction: column;
+}
+
+#error .logo {
+ font-size: 100px;
+}
+
+.desc {
+ font-size: 40px;
+}
+
+input {
+ flex: 0;
+ background-color: #242424;
+ color: white;
+ border: 1px solid #606770;
+}
+
+input:focus {
+ outline: none;
+}
+
+#admin {
+ margin: 1.75em;
+ margin-top: 5em;
+ width: calc(100vw - 1.75em * 2);
+ height: calc(100vh - 5em - 1.75em);
+ display: flex;
+ flex-direction: column;
+}
+
+#queryinput {
+ display: flexbox;
+ width: 100%;
+}
+
+#queryinput #query {
+ width: 50em;
+ margin: 0;
+}
+
+form {
+ width: 100%;
+ display: flex;
+ justify-content: center;
+ align-content: center;
+}
+
+#queryinput .submit, .view {
+ all: unset;
+ font-family: sfpro;
+ margin: 0;
+ padding: 10px 30px;
+ background-color: #3bd16f;
+ border-radius: 5px;
+ font-size: 18px;
+ margin-left: 2em;
+ cursor: pointer;
+ border: 1px solid #606770;
+}
+
+#queryinput .submit:active {
+ background-color: #30ab5a;
+}
+
+#queryinput .view {
+ background-color: #242424;
+ color: #707882;
+ border: 1px solid #606770;
+}
+
+#queryinput .view:active {
+ background-color: #181818;
+}
+
+table {
+ margin-top: 3em;
+ border-collapse: separate;
+ border-spacing: 15px;
+}
+
+th, td {
+ font-family: sfpro;
+ color: white;
+ padding: 20px;
+ border-radius: 10px;
+ background-color: #242424;
+ border-radius: 10px;
+}
+
+th {
+ font-family: sfprobold;
+}
+
+.value {
+ color: white;
+}
+
+.bool {
+ color: aqua;
+}
+
+.null {
+ color: blue;
+}
+
+.number {
+ color: yellow;
+}
+
+.string {
+ color: #4ae04a
+}
+
+.key .string {
+ color: white;
+}
\ No newline at end of file
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..e023946
Binary files /dev/null and b/public/favicon.ico differ
diff --git a/public/js/admin.js b/public/js/admin.js
new file mode 100644
index 0000000..e4364ec
--- /dev/null
+++ b/public/js/admin.js
@@ -0,0 +1,59 @@
+async function auth(event) {
+ event.preventDefault();
+ const text = event.target.elements.adminpassword.value;
+ const response = await adminauth(text);
+ if (response.status !== 200) {
+ alert(response.msg)
+ } else {
+ document.getElementById("admin").classList.remove("hidden")
+ document.getElementById("login").classList.add("hidden")
+ }
+ return false;
+}
+
+async function submit() {
+ let text = document.getElementById("query").value
+ let response = await adminquery(text)
+ alert(response.msg)
+}
+
+async function posts() {
+ let response = await adminposts();
+ if (response.status !== 200) {
+ alert(response.msg)
+ return
+ }
+ let table = document.getElementById("table")
+ table.innerHTML = response.msg
+}
+
+async function users() {
+ let response = await adminusers();
+ if (response.status !== 200) {
+ alert(response.msg)
+ return
+ }
+ let table = document.getElementById("table")
+ table.innerHTML = response.msg
+}
+
+async function sessions() {
+ let response = await adminsessions();
+ if (response.status !== 200) {
+ alert(response.msg)
+ return
+ }
+ let table = document.getElementById("table")
+ table.innerHTML = response.msg
+}
+
+async function load() {
+ let check = await admincheck();
+ if (check.msg === "true") {
+ document.getElementById("admin").classList.remove("hidden")
+ } else {
+ document.getElementById("login").classList.remove("hidden")
+ }
+}
+
+load()
\ No newline at end of file
diff --git a/public/js/api.js b/public/js/api.js
index 77adff7..9845be5 100644
--- a/public/js/api.js
+++ b/public/js/api.js
@@ -64,4 +64,28 @@ const postlike = async (post_id, state) => {
const createpost = async (content) => {
return await request('/posts/create', {content})
+}
+
+const adminauth = async (secret) => {
+ return await request('/admin/auth', {secret})
+}
+
+const admincheck = async () => {
+ return await request('/admin/check', {})
+}
+
+const adminquery = async (query) => {
+ return await request('/admin/query', {query})
+}
+
+const adminposts = async () => {
+ return await request('/admin/posts', {})
+}
+
+const adminusers = async () => {
+ return await request('/admin/users', {})
+}
+
+const adminsessions = async () => {
+ return await request('/admin/sessions', {})
}
\ No newline at end of file
diff --git a/public/login.html b/public/login.html
index 97398f9..e0428b9 100644
--- a/public/login.html
+++ b/public/login.html
@@ -164,7 +164,7 @@
- Metashit © 2023 | This website does not care about you
+ Tyler Murphy © 2023 | tylerm.dev