diff --git a/src/components/createsourceform.vue b/src/components/createsourceform.vue
new file mode 100644
index 0000000..3e27d64
--- /dev/null
+++ b/src/components/createsourceform.vue
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
diff --git a/src/router.js b/src/router.js
index be0fcc5..1afa28e 100644
--- a/src/router.js
+++ b/src/router.js
@@ -21,6 +21,7 @@ import Oauth2 from "./views/Oauth2.vue";
import Register from "./views/Register.vue";
import Login from "./views/Login.vue";
import Logout from "./views/Logout.vue";
+import CreateSource from "./views/CreateSource.vue";
import { parseRef, projectRunLink } from "@/util/link.js";
import { fetchProject } from "@/util/data.js";
@@ -37,6 +38,11 @@ const router = new VueRouter({
name: "register",
component: Register,
},
+ {
+ path: "/newsource",
+ name: "newsource",
+ component: CreateSource,
+ },
{
path: "/login",
name: "login",
@@ -383,4 +389,4 @@ router.beforeEach(async (to, from, next) => {
next()
})
-export default router
\ No newline at end of file
+export default router
diff --git a/src/util/auth.js b/src/util/auth.js
index 0020321..1ffe81e 100644
--- a/src/util/auth.js
+++ b/src/util/auth.js
@@ -64,7 +64,7 @@ export async function registerapi(init) {
return await window.fetch(registerurl(), init);
}
-export async function fetch(url, init, signal) {
+export async function fetch(url, init, signal, token, tokenType = "bearer") {
if (!init) {
init = {};
}
@@ -74,9 +74,9 @@ export async function fetch(url, init, signal) {
if (signal) {
init["signal"] = signal;
}
- let idToken = getIdToken();
+ let idToken = token || getIdToken();
if (idToken) {
- init.headers["Authorization"] = "bearer " + idToken;
+ init.headers["Authorization"] = tokenType + " " + idToken;
}
return await window.fetch(url, init);
diff --git a/src/util/data.js b/src/util/data.js
index a388e8e..d006e39 100644
--- a/src/util/data.js
+++ b/src/util/data.js
@@ -1,9 +1,12 @@
import router from "@/router";
import { apiurl, fetch as authfetch, loginapi, registerapi } from "@/util/auth";
-export async function fetch(url, init, signal) {
+export const GITHUB_API_URL = "https://api.github.com";
+export const GITHUB_SSH_KEY = "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
+
+export async function fetch(url, init, signal, token, tokenType) {
try {
- let res = await authfetch(url, init, signal);
+ let res = await authfetch(url, init, signal, token, tokenType);
if (!res.ok) {
if (res.status === 401) {
router.push({
@@ -186,6 +189,30 @@ export async function fetchVariables(ownertype, ref, all, signal) {
return await fetch(apiurl(path), null, signal);
}
+export async function createRemoteSource(
+ token, type, name, clientID, clientSecret, apiURL, authType, skipVerify,
+ sshHostKey, skipSshHostKeyCheck, registrationEnabled, loginEnabled, signal,
+) {
+ let path = "/remotesources";
+ let init = {
+ method: "POST",
+ body: JSON.stringify({
+ name,
+ apiurl: apiURL,
+ type,
+ auth_type: authType,
+ skip_verify: skipVerify,
+ ssh_host_key: sshHostKey,
+ skip_ssh_host_key_check: skipSshHostKeyCheck,
+ oauth_2_client_id: clientID,
+ oauth_2_client_secret: clientSecret,
+ registration_enabled: registrationEnabled,
+ login_enabled: loginEnabled,
+ })
+ };
+ return await fetch(apiurl(path), init, signal, token, "token");
+}
+
export async function createOrganization(orgname, visibility, signal) {
let path = "/orgs";
let init = {
@@ -390,3 +417,4 @@ export async function deleteProjectGroup(projectgroupref, signal) {
};
return await fetch(apiurl(path), init, signal);
}
+
diff --git a/src/views/CreateSource.vue b/src/views/CreateSource.vue
new file mode 100644
index 0000000..68b8572
--- /dev/null
+++ b/src/views/CreateSource.vue
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
diff --git a/src/views/Login.vue b/src/views/Login.vue
index bb4c90a..c857fe4 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -13,6 +13,14 @@
class="mb-10 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
>
No remote sources defined
+
+
+
No remote sources defined
+
+
+