Compare commits
	
		
			2 Commits
		
	
	
		
			gitea-runn
			...
			fix-import
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						d44699e9f8
	
				 | 
					
					
						|||
| 
						
						
							
						
						2010556643
	
				 | 
					
					
						
@@ -51,11 +51,11 @@ in {
 | 
				
			|||||||
        START_SSH_SERVER = true;
 | 
					        START_SSH_SERVER = true;
 | 
				
			||||||
        START_LFS_SERVER = true;
 | 
					        START_LFS_SERVER = true;
 | 
				
			||||||
        LFS_JWT_SECRET = lib.mkForce "";
 | 
					        LFS_JWT_SECRET = lib.mkForce "";
 | 
				
			||||||
        LFS_JWT_SECRET_URI = config.sops.secrets."gitea/lfs-jwt-secret".path;
 | 
					        LFS_JWT_SECRET_URI = "file:${config.sops.secrets."gitea/lfs-jwt-secret".path}";
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      oauth2 = {
 | 
					      oauth2 = {
 | 
				
			||||||
        JWT_SECRET = lib.mkForce "";
 | 
					        JWT_SECRET = lib.mkForce "";
 | 
				
			||||||
        JWT_SECRET_URI = config.sops.secrets."gitea/oauth2-jwt-secret".path;
 | 
					        JWT_SECRET_URI = "file:${config.sops.secrets."gitea/oauth2-jwt-secret".path}";
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      "git.timeout" = {
 | 
					      "git.timeout" = {
 | 
				
			||||||
        MIGRATE = 3600;
 | 
					        MIGRATE = 3600;
 | 
				
			||||||
@@ -85,7 +85,7 @@ in {
 | 
				
			|||||||
      session.COOKIE_SECURE = true;
 | 
					      session.COOKIE_SECURE = true;
 | 
				
			||||||
      security = {
 | 
					      security = {
 | 
				
			||||||
        SECRET_KEY = lib.mkForce "";
 | 
					        SECRET_KEY = lib.mkForce "";
 | 
				
			||||||
        SECRET_KEY_PATH = config.sops.secrets."gitea/secret-key".path;
 | 
					        SECRET_KEY_URI = "file:${config.sops.secrets."gitea/secret-key".path}";
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      database.LOG_SQL = false;
 | 
					      database.LOG_SQL = false;
 | 
				
			||||||
      repository = {
 | 
					      repository = {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,8 @@ in
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  systemd.services.gitea-import-users = lib.mkIf cfg.enable {
 | 
					  systemd.services.gitea-import-users = lib.mkIf cfg.enable {
 | 
				
			||||||
    enable = true;
 | 
					    enable = true;
 | 
				
			||||||
    preStart=''${pkgs.rsync}/bin/rsync -e "${pkgs.openssh}/bin/ssh -o UserKnownHostsFile=$CREDENTIALS_DIRECTORY/ssh-known-hosts -i $CREDENTIALS_DIRECTORY/sshkey" -a pvv@smtp.pvv.ntnu.no:/etc/passwd /tmp/passwd-import'';
 | 
					    preStart=''${pkgs.rsync}/bin/rsync -e "${pkgs.openssh}/bin/ssh -o UserKnownHostsFile=$CREDENTIALS_DIRECTORY/ssh-known-hosts -i $CREDENTIALS_DIRECTORY/sshkey" -a pvv@smtp.pvv.ntnu.no:/etc/passwd /run/gitea-import-users/passwd'';
 | 
				
			||||||
 | 
					    environment.PASSWD_FILE_PATH = "/run/gitea-import-users/passwd";
 | 
				
			||||||
    serviceConfig = {
 | 
					    serviceConfig = {
 | 
				
			||||||
      ExecStart = pkgs.writers.writePython3 "gitea-import-users" {
 | 
					      ExecStart = pkgs.writers.writePython3 "gitea-import-users" {
 | 
				
			||||||
        flakeIgnore = [
 | 
					        flakeIgnore = [
 | 
				
			||||||
@@ -25,6 +26,7 @@ in
 | 
				
			|||||||
      ];
 | 
					      ];
 | 
				
			||||||
      DynamicUser="yes";
 | 
					      DynamicUser="yes";
 | 
				
			||||||
      EnvironmentFile=config.sops.secrets."gitea/import-user-env".path;
 | 
					      EnvironmentFile=config.sops.secrets."gitea/import-user-env".path;
 | 
				
			||||||
 | 
					      RuntimeDirectory = "gitea-import-users";
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,10 @@ GITEA_API_URL = os.getenv('GITEA_API_URL')
 | 
				
			|||||||
if GITEA_API_URL is None:
 | 
					if GITEA_API_URL is None:
 | 
				
			||||||
    GITEA_API_URL = 'https://git.pvv.ntnu.no/api/v1'
 | 
					    GITEA_API_URL = 'https://git.pvv.ntnu.no/api/v1'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PASSWD_FILE_PATH = os.getenv('PASSWD_FILE_PATH')
 | 
				
			||||||
 | 
					if PASSWD_FILE_PATH is None:
 | 
				
			||||||
 | 
					    PASSWD_FILE_PATH = '/tmp/passwd-import'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def gitea_list_all_users() -> dict[str, dict[str, any]] | None:
 | 
					def gitea_list_all_users() -> dict[str, dict[str, any]] | None:
 | 
				
			||||||
    r = requests.get(
 | 
					    r = requests.get(
 | 
				
			||||||
@@ -187,7 +191,8 @@ def main():
 | 
				
			|||||||
    if existing_users is None:
 | 
					    if existing_users is None:
 | 
				
			||||||
        exit(1)
 | 
					        exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for username, name in passwd_file_parser("/tmp/passwd-import"):
 | 
					    print(f"Reading passwd entries from {PASSWD_FILE_PATH}")
 | 
				
			||||||
 | 
					    for username, name in passwd_file_parser(PASSWD_FILE_PATH):
 | 
				
			||||||
        print(f"Processing {username}")
 | 
					        print(f"Processing {username}")
 | 
				
			||||||
        add_or_patch_gitea_user(username, name, existing_users)
 | 
					        add_or_patch_gitea_user(username, name, existing_users)
 | 
				
			||||||
        for org, team_name in COMMON_USER_TEAMS:
 | 
					        for org, team_name in COMMON_USER_TEAMS:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user