Compare commits
2 Commits
feat/optio
...
push-uymll
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da67da6f11 | ||
|
|
a417778a53 |
@@ -4,13 +4,14 @@ let
|
||||
in
|
||||
{
|
||||
clan.modules.users = module;
|
||||
|
||||
perSystem =
|
||||
{ ... }:
|
||||
{
|
||||
clan.nixosTests.users = {
|
||||
imports = [ ./tests/vm/default.nix ];
|
||||
|
||||
clan.modules."@clan/users" = module;
|
||||
clan.modules.users = module;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,50 +2,71 @@
|
||||
name = "service-users";
|
||||
|
||||
clan = {
|
||||
test.useContainers = false;
|
||||
directory = ./.;
|
||||
inventory = {
|
||||
machines.server = { };
|
||||
machines.machine = { };
|
||||
|
||||
instances = {
|
||||
root-password-test = {
|
||||
module.name = "@clan/users";
|
||||
users-root = {
|
||||
module.name = "users";
|
||||
module.input = "self";
|
||||
roles.default.machines."server".settings = {
|
||||
roles.default.machines.machine.settings = {
|
||||
user = "root";
|
||||
prompt = false;
|
||||
};
|
||||
};
|
||||
user-password-test = {
|
||||
module.name = "@clan/users";
|
||||
users-testuser = {
|
||||
module.name = "users";
|
||||
module.input = "self";
|
||||
roles.default.machines."server".settings = {
|
||||
roles.default.machines.machine.settings = {
|
||||
user = "testuser";
|
||||
prompt = false;
|
||||
};
|
||||
};
|
||||
users-admin = {
|
||||
module.name = "users";
|
||||
module.input = "self";
|
||||
roles.default.machines.machine.settings = {
|
||||
user = "admin";
|
||||
prompt = false;
|
||||
groups = [ "wheel" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nodes = {
|
||||
server = {
|
||||
users.users.testuser.group = "testuser";
|
||||
users.groups.testuser = { };
|
||||
};
|
||||
machine =
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
environment.systemPackages = [ pkgs.tree ]; # TODO: debug
|
||||
|
||||
clan.core.vars.generators.user-password-root.files.user-password.deploy = lib.mkForce true;
|
||||
clan.core.vars.generators.user-password-testuser.files.user-password.deploy = lib.mkForce true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
|
||||
server.wait_for_unit("multi-user.target")
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
|
||||
# Check that the testuser account exists
|
||||
server.succeed("id testuser")
|
||||
# Assert that the testuser exists
|
||||
machine.succeed("id testuser")
|
||||
|
||||
# Try to log in as the user using the generated password
|
||||
# TODO: fix
|
||||
# password = server.succeed("cat /run/clan/vars/user-password/user-password").strip()
|
||||
# server.succeed(f"echo '{password}' | su - testuser -c 'echo Login successful'")
|
||||
# TODO: debug
|
||||
machine.succeed("tree /run/secrets/vars")
|
||||
|
||||
machine.fail("su - admin -c 'echo wrong-password | su - testuser -c \"echo Login successful\"'")
|
||||
|
||||
output = machine.succeed("sudo --reset-timestamp --stdin -u testuser echo Login successful < /run/secrets/vars/user-password-testuser/user-password")
|
||||
assert output.strip() == "Login successful", f"Failed to log in as testuser: {output=}"
|
||||
|
||||
machine.fail("sudo --reset-timestamp --stdin -iu root echo Login successful < /run/secrets/vars/user-password-testuser/user-password")
|
||||
|
||||
output = machine.succeed("sudo --reset-timestamp --stdin -u root echo Login successful < /run/secrets/vars/user-password-root/user-password")
|
||||
assert output.strip() == "Login successful", f"Failed to log in as root: {output=}"
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
{% extends "base.html" %} {% block extrahead %}
|
||||
<style>
|
||||
|
||||
.md-main__inner {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
.md-content {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
.md-main__inner {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %} {% block site_nav %}{% endblock %} {% block content %} {{
|
||||
page.content }} {% endblock %}
|
||||
|
||||
@@ -2,86 +2,5 @@
|
||||
template: options.html
|
||||
---
|
||||
|
||||
<script>
|
||||
|
||||
const variables = [
|
||||
'--md-default-bg-color',
|
||||
'--md-default-fg-color',
|
||||
'--md-default-fg-color--light',
|
||||
'--md-default-fg-color--lightest'
|
||||
];
|
||||
|
||||
let colorScheme = 'default';
|
||||
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'data-md-color-scheme') {
|
||||
colorScheme = mutation.target.getAttribute('data-md-color-scheme');
|
||||
console.log('color scheme changed', colorScheme);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
attributes: true,
|
||||
attributeFilter: ['data-md-color-scheme']
|
||||
});
|
||||
|
||||
function syncCSSVariables() {
|
||||
const iframe = document.getElementById('options-frame');
|
||||
console.log('syncing css variables', iframe);
|
||||
|
||||
const iframeDoc = iframe.contentWindow.document;
|
||||
const iframeRoot = iframeDoc.documentElement;
|
||||
|
||||
const targetElement = document.querySelector(`[data-md-color-scheme="${colorScheme}"]`);
|
||||
const parentStyles = getComputedStyle(targetElement);
|
||||
|
||||
console.log('parent styles', parentStyles);
|
||||
|
||||
variables.forEach(varName => {
|
||||
const value = parentStyles.getPropertyValue(varName);
|
||||
if (value.trim()) {
|
||||
console.log('setting', varName, value);
|
||||
iframeRoot.style.setProperty(varName, value.trim());
|
||||
}
|
||||
});
|
||||
|
||||
// add our custom styling
|
||||
addCustomCSS(iframe);
|
||||
}
|
||||
|
||||
|
||||
function addCustomCSS(iframe) {
|
||||
const iframeDoc = iframe.contentWindow.document;
|
||||
|
||||
const cssLink = iframeDoc.createElement('link');
|
||||
cssLink.id = "clan-css";
|
||||
cssLink.rel = "stylesheet";
|
||||
cssLink.type = "text/css";
|
||||
cssLink.href = "/static/options.css";
|
||||
|
||||
iframeDoc.head.appendChild(cssLink);
|
||||
}
|
||||
|
||||
function onIFrameLoad() {
|
||||
const iframe = document.getElementById('options-frame');
|
||||
|
||||
// initial sync of css variables
|
||||
syncCSSVariables(iframe);
|
||||
|
||||
// listen for theme changes
|
||||
const darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
const lightModeQuery = window.matchMedia('(prefers-color-scheme: light)');
|
||||
|
||||
darkModeQuery.addEventListener('change', syncCSSVariables);
|
||||
lightModeQuery.addEventListener('change', syncCSSVariables);
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<iframe id="options-frame" src="/options-page/" onload="onIFrameLoad()" height="1000" width="100%"></iframe>
|
||||
|
||||
[asciinema-player](static/asciinema-player)
|
||||
<iframe src="/options-page/" height="1000" width="100%"></iframe>
|
||||
|
||||
@@ -20,7 +20,3 @@
|
||||
.md-nav__item.md-nav__item--section > label > span {
|
||||
color: var(--md-typeset-a-color);
|
||||
}
|
||||
|
||||
iframe {
|
||||
border: none;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
@font-face {
|
||||
font-family: "Roboto";
|
||||
src: url(./Roboto-Regular.ttf) format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Fira Code";
|
||||
src: url(./FiraCode-VF.ttf) format("truetype");
|
||||
}
|
||||
|
||||
:root {
|
||||
--f-family: "Roboto";
|
||||
--f-family-mono: "Fira Code";
|
||||
|
||||
--c-page: var(--md-default-bg-color);
|
||||
--c-card: transparent;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
color: var(--md-default-fg-color--light);
|
||||
}
|
||||
|
||||
div.card {
|
||||
border: .05rem solid var(--md-default-fg-color--lightest) !important;
|
||||
}
|
||||
|
||||
|
||||
form {
|
||||
label {
|
||||
gap: 1rem;
|
||||
|
||||
input {
|
||||
background-color: #00000042 !important;
|
||||
|
||||
&:hover {
|
||||
background-color: #ffffff1f !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user