forked from dzikoysk/reposilite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dzikoyskGH-17 Add dashboard view with login component and index with …
…auth support
Showing
23 changed files
with
348 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
reposilite-backend/src/main/java/org/panda_lang/reposilite/api/AuthApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.panda_lang.reposilite.api; | ||
|
||
import io.javalin.http.Context; | ||
import org.apache.http.HttpStatus; | ||
import org.panda_lang.reposilite.RepositoryController; | ||
import org.panda_lang.reposilite.auth.Authenticator; | ||
import org.panda_lang.reposilite.auth.Session; | ||
import org.panda_lang.reposilite.config.Configuration; | ||
|
||
public final class AuthApiController implements RepositoryController { | ||
|
||
private final Configuration configuration; | ||
private final Authenticator authenticator; | ||
|
||
public AuthApiController(Configuration configuration, Authenticator authenticator) { | ||
this.configuration = configuration; | ||
this.authenticator = authenticator; | ||
} | ||
|
||
@Override | ||
public Context handleContext(Context ctx) { | ||
return authenticator | ||
.auth(ctx) | ||
.map(Session::getToken) | ||
.map(token -> new AuthDto(token.getPath(), configuration.getManagers().contains(token.getAlias()))) | ||
.map(ctx::json) | ||
.orElseGet(error -> ctx.status(HttpStatus.SC_UNAUTHORIZED).json(new ErrorDto(HttpStatus.SC_UNAUTHORIZED, error))); | ||
} | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
reposilite-backend/src/main/java/org/panda_lang/reposilite/api/AuthDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.panda_lang.reposilite.api; | ||
|
||
import java.io.Serializable; | ||
|
||
final class AuthDto implements Serializable { | ||
|
||
private final String path; | ||
private final boolean isManager; | ||
|
||
AuthDto(String path, boolean isManager) { | ||
this.path = path; | ||
this.isManager = isManager; | ||
} | ||
|
||
public boolean isManager() { | ||
return isManager; | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
reposilite-backend/src/main/java/org/panda_lang/reposilite/api/ErrorUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.panda_lang.reposilite.api; | ||
|
||
import io.javalin.http.Context; | ||
|
||
final class ErrorUtils { | ||
|
||
static Context error(Context context, int status, String message) { | ||
return context.status(status).json(new ErrorDto(status, message)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,4 @@ | ||
!!org.panda_lang.reposilite.stats.StatsEntity | ||
"records": | ||
"/releases/org/panda-lang/reposilite/2.10.0-SNAPSHOT/reposilite-2.10.0-SNAPSHOT.pom.md5": !!int "1" | ||
"/releases/org/panda-lang/reposilite/2.10.0-SNAPSHOT/reposilite-2.10.0-SNAPSHOT.jar": !!int "2" | ||
"/api/releases/org/panda-lang/reposilite-parent/2.5.0/maven-metadata.xml": !!int "1" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/reposilite-test-1.0.0-20200603.224843-1.jar.sha1": !!int "1" | ||
"/api/snapshots/org": !!int "2" | ||
"/api/configuration": !!int "7" | ||
"/api/snapshots": !!int "3" | ||
"/releases/org/panda-lang/reposilite/2.10.0-SNAPSHOT/maven-metadata.xml.sha1": !!int "4" | ||
"/releases/org/panda-lang/reposilite/maven-metadata.xml": !!int "1" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/maven-metadata.xml.sha1": !!int "1" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/reposilite-test-1.0.0-20200603.224843-1.pom": !!int "1" | ||
"/api/snapshots/org/panda-lang": !!int "2" | ||
"/favicon.ico": !!int "1" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/maven-metadata.xml.md5": !!int "1" | ||
"/api/snapshots/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT": !!int "1" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/maven-metadata.xml": !!int "2" | ||
"/": !!int "2" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/reposilite-test-1.0.0-20200603.224843-1.jar.md5": !!int "1" | ||
"/snapshots/org/panda-lang/reposilite-test/maven-metadata.xml": !!int "1" | ||
"/releases/org/x": !!int "1" | ||
"/api/": !!int "4" | ||
"/releases/org/panda-lang/reposilite-test/maven-metadata.xml": !!int "3" | ||
"/api/snapshots/org/panda-lang/reposilite-test": !!int "2" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/reposilite-test-1.0.0-20200603.224843-1.pom.sha1": !!int "1" | ||
"/releases/org/panda-lang/reposilite/2.10.0-SNAPSHOT/reposilite-2.10.0-SNAPSHOT.pom": !!int "1" | ||
"/releases/org/panda-lang/reposilite-test/maven-metadata.xml.md5": !!int "1" | ||
"/api/releases/org/panda-lang/reposilite/2.10.0-SNAPSHOT/maven-metadata.xml": !!int "2" | ||
"/js/app.js": !!int "7" | ||
"/releases/org/panda-lang/reposilite/2.10.0-SNAPSHOT/reposilite-2.10.0-SNAPSHOT.pom.sha1": !!int "1" | ||
"/releases/org/panda-lang/reposilite-test/maven-metadata.xml.sha1": !!int "3" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/reposilite-test-1.0.0-20200603.224843-1.jar": !!int "1" | ||
"/releases/org/panda-lang/reposilite/2.10.0-SNAPSHOT/maven-metadata.xml": !!int "8" | ||
"/releases/org/panda-lang/reposilite-parent/2.5.0/maven-metadata.xml": !!int "2" | ||
"/releases/org/panda-lang/reposilite-test/1.0.0-SNAPSHOT/reposilite-test-1.0.0-20200603.224843-1.pom.md5": !!int "1" | ||
"/releases/auth/test/test.jar": !!int "5" | ||
"/api/releases/org": !!int "1" | ||
"/api/releases": !!int "1" | ||
"/api/releases/org/x": !!int "1" | ||
"/api/auth": !!int "6" | ||
"/api/": !!int "19" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<template lang="pug"> | ||
form#login(v-if="!auth.verified").p-8.text-center(method="post").border-dashed.border-black.border-1.rounded | ||
h1.font-bold.py-4.text-xl Login | ||
div.py-1 | ||
input(placeholder="Alias" name="alias" v-model="auth.alias").w-96.p-1 | ||
div.py-1 | ||
input(placeholder="Token" name="token" v-model="auth.token" autocomple="on").w-96.p-1 | ||
div.py-3 | ||
button.bg-gray-300.px-6.py-1.mt-1(v-on:click="login") Login | ||
div.py-1 | ||
p(v-if="error") {{ this.error }} | ||
</template> | ||
|
||
<script> | ||
export default { | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const url = ((process.env.NODE_ENV == 'production') ? '/' : 'http://localhost:80/') + 'api'; | ||
|
||
export default { | ||
methods: { | ||
api(uri, credentials) { | ||
return this.$http.get(url + uri, { auth: credentials }) | ||
}, | ||
parentPath() { | ||
const elements = ('/' + this.getQualifier()).split('/') | ||
elements.pop() | ||
let path = this.normalize(elements.join('/')) | ||
return path.length == 0 ? '/' : path | ||
}, | ||
getQualifier() { | ||
return this.normalize(this.$route.params['qualifier']) | ||
}, | ||
normalize(uri) { | ||
if (uri === undefined) { | ||
return '/' | ||
} | ||
|
||
if (!uri.startsWith('/')) { | ||
uri = '/' + uri | ||
} | ||
|
||
if (uri.length > 1 && uri.endsWith('/')) { | ||
uri = uri.substr(0, uri.length - 1) | ||
} | ||
|
||
return uri | ||
} | ||
} | ||
} |
Oops, something went wrong.