feat(backend): add SUPERADMIN_SECRET as an env set superadmin

This commit is contained in:
Ruben Fiszel
2022-12-22 10:35:10 +01:00
parent 962c14639c
commit 1ddb1f2f59
7 changed files with 49 additions and 28 deletions
+2
View File
@@ -302,6 +302,8 @@ upcoming CLI tool.
| PATH | None | The path environment variable, usually inherited | Worker |
| HOME | None | The home directory to use for Go and Bash , usually inherited | Worker |
| DATABASE_CONNECTIONS | 50 (Server)/3 (Worker) | The max number of connections in the database connection pool | All |
| SUPERADMIN_SECRET | None | A token that would let the caller act as a virtual superadmin superadmin@windmill.dev | Server |
## Run a local dev setup
+4 -1
View File
@@ -64,7 +64,10 @@ pub async fn run_server(
) -> anyhow::Result<()> {
let user_db = UserDB::new(db.clone());
let auth_cache = Arc::new(users::AuthCache::new(db.clone()));
let auth_cache = Arc::new(users::AuthCache::new(
db.clone(),
std::env::var("SUPERADMIN_SECRET").ok(),
));
let argon2 = Arc::new(Argon2::default());
let basic_clients = Arc::new(build_oauth_clients(&base_url).await?);
let slack_verifier = Arc::new(
+1 -1
View File
@@ -40,7 +40,7 @@
box-shadow: none !important;
}
.monaco-editor span.mtk20 {
.templatable-editor span.mtk20 {
color: black !important;
}
}
@@ -398,8 +398,8 @@
</ol>
</div>
{#if apiTokenApps[resource_type].img}
<div class="mt-4">
<img alt="connect" src={apiTokenApps[resource_type].img} />
<div class="mt-4 w-full">
<img class="max-h-96 m-auto" alt="connect" src={apiTokenApps[resource_type].img} />
</div>
{/if}
{/if}
+1 -1
View File
@@ -70,7 +70,7 @@
if (path == '' || path == 'u//') {
meta = { ownerKind: 'user', name: namePlaceholder, owner: '' }
meta.owner = $userStore!.username
meta.owner = $userStore!.username.split('@')[0]
let i = 1
while (await pathExists(metaToPath(meta), kind)) {
@@ -568,7 +568,7 @@
})
</script>
<div bind:this={divEl} class="{$$props.class} editor" bind:clientWidth={width} />
<div bind:this={divEl} class="{$$props.class} editor templatable-editor" bind:clientWidth={width} />
<style>
.editor {
+38 -22
View File
@@ -15,14 +15,15 @@
import { superadmin, usersWorkspaceStore, userWorkspaces, workspaceStore } from '$lib/stores'
import { faCrown, faUserCog } from '@fortawesome/free-solid-svg-icons'
import Icon from 'svelte-awesome'
import { Button } from '$lib/components/common'
import { Button, Skeleton } from '$lib/components/common'
import Toggle from '$lib/components/Toggle.svelte'
import UserSettings from '$lib/components/UserSettings.svelte'
import SuperadminSettings from '$lib/components/SuperadminSettings.svelte'
import { WindmillIcon } from '$lib/components/icons'
let invites: WorkspaceInvite[] = []
let list_all_as_super_admin: boolean = false
let workspaces: { id: string; name: string; username: string }[] = []
let workspaces: { id: string; name: string; username: string }[] | undefined = undefined
let userSettings: UserSettings
let superadminSettings: SuperadminSettings
@@ -66,6 +67,7 @@
loadInvites()
loadWorkspaces()
let loading = false
</script>
{#if $superadmin}
@@ -80,7 +82,13 @@
<p class="text-center font-medium text-gray-600 text-xs mb-10">
Logged in as {$usersWorkspaceStore?.email}
</p>
<h2 class="mb-4">Workspaces</h2>
<h2 class="mb-4 inline-flex gap-2"
>Workspaces{#if loading}<WindmillIcon
class="animate-[pulse_5s_linear_infinite] animate-[spin_5s_linear_infinite]"
/>
{/if}
</h2>
{#if $superadmin}
<div class="flex flex-row-reverse pb-4">
<Toggle
@@ -89,26 +97,34 @@
/>
</div>
{/if}
{#if workspaces.length == 0}
<p class="text-sm text-gray-600 mt-2">
You are not a member of any workspace yet. Accept an invitation or create your own
workspace.
</p>
{/if}
{#each workspaces as workspace}
<label class="block pb-2">
<button
class="block w-full mx-auto py-1 px-2 rounded-md border border-gray-300
{#if workspaces}
{#if workspaces.length == 0}
<p class="text-sm text-gray-600 mt-2">
You are not a member of any workspace yet. Accept an invitation or create your own
workspace.
</p>
{/if}
{#each workspaces as workspace}
<label class="block pb-2">
<button
class="block w-full mx-auto py-1 px-2 rounded-md border border-gray-300
shadow-sm text-sm font-normal mt-1 hover:ring-1 hover:ring-indigo-300"
on:click={() => {
workspaceStore.set(workspace.id)
goto(rd ?? '/')
}}
><span class="font-mono">{workspace.id}</span> - {workspace.name} as
<span class="font-mono">{workspace.username}</span>
</button>
</label>
{/each}
on:click={async () => {
workspaceStore.set(workspace.id)
loading = true
await goto(rd ?? '/')
loading = false
}}
><span class="font-mono">{workspace.id}</span> - {workspace.name} as
<span class="font-mono">{workspace.username}</span>
</button>
</label>
{/each}
{:else}
{#each new Array(3) as _}
<Skeleton layout={[[2], 0.5]} />
{/each}
{/if}
<div class="flex flex-row-reverse pt-4">
<Button
size="sm"