File modules/cms/auth/IdentAuth.class.php

Last commit: Sun Nov 29 21:46:57 2020 +0100	Jan Dankert	Auth modules should only use the Auth::STATUS_* constants as return value.
1 <?php 2 3 namespace cms\auth; 4 5 use logger\Logger; 6 use util\Http; 7 8 /** 9 * Authentifizierung via Ident-Server. 10 * 11 * Der Benutzername wird über einen Ident-Server, der auf dem 12 * Client installiert sein muss, ermittelt. 13 * 14 * @author dankert 15 */ 16 class IdentAuth implements Auth 17 { 18 public function username() 19 { 20 $ip = Http::getClientIP(); 21 $port = Http::getClientPort(); 22 $identPort = 113; 23 if (!$socket = @fsockopen($ip, $identPort, $errno, $errstr, 10)) { 24 return null; 25 } 26 27 $line = $port . ',' . $_SERVER['SERVER_PORT'] . "\r\n"; 28 @fwrite($socket, $line); 29 $line = @fgets($socket, 1000); // 1000 octets according to RFC 1413 30 fclose($socket); 31 32 $array = explode(':', $line, 4); 33 if (count($array) >= 4 && !strcasecmp(trim($array[1]), 'USERID')) { 34 $username = trim($array[3]); 35 Logger::debug('Ident: User-Id: ' . $username); 36 return $username; 37 } elseif (count($array) >= 3 && !strcasecmp(trim($array[1]), 'ERROR')) { 38 Logger::debug('Ident: Error: ' . trim($array[2])); 39 return null; 40 } else { 41 Logger::warn('Ident: Invalid ident server response: ' . $line); 42 return null; 43 } 44 } 45 46 47 /** 48 * Ueberpruefen des Kennwortes ist über Ident nicht möglich. 49 */ 50 public function login($user, $password, $token) 51 { 52 return Auth::STATUS_FAILED; 53 } 54 }
Download modules/cms/auth/IdentAuth.class.php
History Sun, 29 Nov 2020 21:46:57 +0100 Jan Dankert Auth modules should only use the Auth::STATUS_* constants as return value. Mon, 16 Nov 2020 13:21:57 +0100 Jan Dankert Code cleanup: Externalize calling the auth modules. Tue, 29 Sep 2020 21:34:01 +0200 Jan Dankert Refactoring: Do not use global constants. Sun, 23 Feb 2020 04:49:34 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 2. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.