drasl: init - minecraft auth server (unmojang)

This commit is contained in:
eyjhb 2025-04-06 23:16:36 +02:00
parent 9a87a9e132
commit 4436f3918b
Signed by: eyjhb
GPG key ID: 609F508E3239F920
10 changed files with 191 additions and 0 deletions

View file

@ -0,0 +1,24 @@
diff --git a/flake.nix b/flake.nix
index f6cfa25..68358a8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -101,6 +101,7 @@
in {
options.services.drasl = {
enable = mkEnableOption (lib.mdDoc ''drasl'');
+ package = mkPackageOption { drasl = self.defaultPackage.${pkgs.system}; } "drasl" {};
settings = mkOption {
type = format.type;
default = {};
@@ -115,10 +116,9 @@
wantedBy = ["multi-user.target"];
serviceConfig = let
- pkg = self.defaultPackage.${pkgs.system};
config = format.generate "config.toml" cfg.settings;
in {
- ExecStart = "${pkg}/bin/drasl -config ${config}";
+ ExecStart = "${cfg.package}/bin/drasl -config ${config}";
DynamicUser = true;
StateDirectory = "drasl";
Restart = "always";

View file

@ -0,0 +1,14 @@
diff --git a/config.go b/config.go
index 24e17b5..11194e6 100644
--- a/config.go
+++ b/config.go
@@ -393,6 +393,9 @@ func CleanConfig(config *Config) error {
return fmt.Errorf("Duplicate RegistrationOIDC Name: %s", oidcConfig.Name)
}
oidcNames.Add(oidcConfig.Name)
+ envkey := fmt.Sprintf("DRASL_REGISTRATION_OIDC_%s_CLIENT_SECRET", strings.ToUpper(oidcConfig.Name))
+ envvalue := strings.TrimSpace(Getenv(envkey, oidcConfig.ClientSecret))
+ oidcConfig.ClientSecret = envvalue
oidcConfig.Issuer, err = cleanURL(
fmt.Sprintf("RegistrationOIDC %s Issuer", oidcConfig.Name),
mo.Some("https://idm.example.com/oauth2/openid/drasl"),

View file

@ -20,4 +20,14 @@ in sources // {
# })
];
};
drasl = pkgs.applyPatches {
src = sources.drasl;
name = "drasl-patched";
patches = [
./../patches/drasl-flakes-nix-add-option-package.patch
./../patches/drasl-registration-oidc-env.patch
];
};
}

View file

@ -23,6 +23,25 @@
"url": "https://github.com/nix-community/disko/archive/19c1140419c4f1cdf88ad4c1cfb6605597628940.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"drasl": {
"sha256": "08fxv66qx5a8q52ci0hw2yvxx14a3mdsds5i79brxc1hilxiaksw",
"type": "tarball",
"url": "https://github.com/unmojang/drasl/archive/v3.0.0.tar.gz",
"url_template": "https://github.com/unmojang/drasl/archive/<version>.tar.gz",
"version": "v3.0.0"
},
"flake-compat": {
"branch": "master",
"description": null,
"homepage": null,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"sha256": "19d2z6xsvpxm184m41qrpi1bplilwipgnzv9jy17fgw421785q1m",
"type": "tarball",
"url": "https://github.com/edolstra/flake-compat/archive/ff81ac966bb2cae68946d5ed5fc4994f96d0ffec.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"impermanence": {
"branch": "master",
"description": "Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]",