-
Notifications
You must be signed in to change notification settings - Fork 0
fix(config.sample): remove Host Header Injection risk in OAuth redirectUri + doc improvements #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
102180b
e0ab65a
c259c18
d574a8b
db31569
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,48 @@ | ||
| <?php | ||
| require_once(__DIR__ . '/../vendor/autoload.php'); | ||
| use League\OAuth2\Client\Provider\GenericProvider; | ||
| /* Ficheiro de configuração | ||
| Mais informação sobre o ficheiro de configuração está na documentação. | ||
| */ | ||
|
|
||
| // Email configuration | ||
| // Configuração da Base de Dados | ||
| $db = array( | ||
| 'tipo' => 'mysql', // Apenas há suporte a MYSQL (mysql = mariadb) por enquanto | ||
| 'servidor' => 'localhost', | ||
| 'user' => 'reservasalas', | ||
| // Defina uma password forte antes de usar em produção e restrinja as permissões deste utilizador da DB ao mínimo necessário. | ||
| 'password' => '', | ||
| 'db' => 'reservasalas', | ||
|
Comment on lines
+11
to
+15
|
||
| 'porta' => 3306 | ||
| ); | ||
|
|
||
| // Configuração do servidor de email | ||
| $mail = array( | ||
| 'ativado' => true, | ||
| 'servidor' => 'smtp.gmail.com', | ||
| 'porta' => 465, | ||
| 'autenticacao' => true, | ||
| // caso a autenticação seja por starttls, usar PHPMailer::ENCRYPTION_STARTTLS | ||
| // caso a autenticação seja por ssl, usar PHPMailer::ENCRYPTION_SMTPS | ||
| // caso não seja necessário autenticação, por false na opção autenticacao, e não importar-se para os outros | ||
| 'tipodeseguranca' => 'PHPMailer::ENCRYPTION_STARTTLS ou PHPMailer::ENCRYPTION_SMTPS', | ||
| // Tipo de Segurança: | ||
| // - Para STARTTLS (normalmente porta 587), usar \PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS | ||
| // - Para SMTPS/SSL (normalmente porta 465), usar \PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS | ||
| // - Se não for necessária autenticação, definir 'autenticacao' => false e ajustar esta opção conforme necessário | ||
| 'tipodeseguranca' => \PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS, | ||
| 'username' => '', | ||
| 'fromname' => 'Reserva de Salas', | ||
| 'mailfrom' => '', | ||
| 'password' => '' | ||
| ); | ||
|
|
||
| // Database configuration (MySQL/MariaDB) | ||
| // SECURITY: Use strong passwords and restrict database user permissions | ||
| $db = array( | ||
| 'tipo' => 'mysql', | ||
| 'servidor' => 'localhost', | ||
| 'user' => 'reservasalas', | ||
| 'password' => 'salaspass', // CHANGE THIS to a strong password | ||
| 'db' => 'reservasalas', | ||
| 'porta' => 3306 | ||
| ); | ||
|
|
||
| // OAuth 2.0 configuration | ||
| // SECURITY: Keep clientId and clientSecret confidential | ||
| // Configuração do Fornecedor de Autenticação (OAuth 2.0) | ||
| // IMPORTANTE: Manter o clientSecret confidencial e nunca o expor publicamente. | ||
| // O redirectUri deve ser um URL estático/configurado explicitamente — não use $_SERVER['HTTP_HOST'] | ||
| // diretamente pois pode ser manipulado (Host Header Injection). | ||
| $provider = new GenericProvider([ | ||
| 'urlAuthorize' => 'https://authentik.devenv.marcopisco.com/application/o/authorize/', | ||
| 'urlAccessToken' => 'https://authentik.devenv.marcopisco.com/application/o/token/', | ||
| 'urlResourceOwnerDetails' => 'https://authentik.devenv.marcopisco.com/application/o/userinfo/', | ||
| 'clientId' => 'clientid', // CHANGE THIS | ||
| 'clientSecret' => 'clientsecret', // CHANGE THIS and keep it secret | ||
| 'redirectUri' => 'https://' . $_SERVER['HTTP_HOST'] . '/login' | ||
| 'urlAuthorize' => 'https://exemplo.dominio.pt/application/o/authorize/', | ||
| 'urlAccessToken' => 'https://exemplo.dominio.pt/application/o/token/', | ||
| 'urlResourceOwnerDetails' => 'https://exemplo.dominio.pt/application/o/userinfo/', | ||
| 'clientId' => '', | ||
| 'clientSecret' => '', | ||
| 'redirectUri' => 'https://exemplo.dominio.pt/login' | ||
| ]); | ||
| ?> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ao renomear a secção de instalação para "Dependências" foi removido o passo que apontava para as instruções de criação/configuração do utilizador MySQL/MariaDB. Se essa configuração continua necessária (criação do user/permissões), o README fica incompleto para uma instalação nova; sugiro reintroduzir um link/passo equivalente (Wiki/Manual do Técnico) nesta secção.