Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,34 @@ SITENAME="MunkiReport"
#
# AUTH_METHODS can be one of
# - "NOAUTH": No authentication
# - "ENV": Environment variable (without password) Authentication
# - "LOCAL" : Local Users defined as .yml in the "users" folder
# - "LDAP": LDAP Authentication
# - "AD": Active Directory Authentication
# - Any combination of the above, comma separated.
#
# Authentication providers are checked in this order:
# - Noauth
# - Environment variable
# - Generated local user
# - LDAP
# - Active Directory


AUTH_METHODS="NOAUTH"

# ENVIRONMENT VARIABLE AUTHENTICATION
# -------------------------------
#
# Read the authenticated username from the
# given server environment variable. Useful
# for handling authentication via a reverse
# proxy (i.e. HTTP header, forward auth, Kerberos)
AUTH_ENV_USER_VAR="REMOTE_USER"
# Set to TRUE to fail authentication if the
# above-named variable is empty or missing.
AUTH_ENV_DENY_EMPTY=FALSE

# ACTIVE DIRECTORY AUTHENTICATION
# -------------------------------
#
Expand Down
3 changes: 2 additions & 1 deletion app/config/auth/env.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

return [
'env_user_var' => 'REMOTE_USER',
'env_user_var' => env('AUTH_ENV_USER_VAR', 'REMOTE_USER'),
'env_user_deny_empty' => env('AUTH_ENV_DENY_EMPTY', false),
];
19 changes: 16 additions & 3 deletions app/lib/munkireport/AuthEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class AuthEnv extends AbstractAuth
{
private $config;
private $config, $login, $authStatus;

public function __construct($config)
{
Expand All @@ -13,6 +13,19 @@ public function __construct($config)

public function login($login, $password)
{
$this->login = getenv($this->config['env_user_var']);

if ($this->config['env_user_deny_empty'] && empty($this->login)) {
if ($this->login === '') {
$this->authStatus = 'unauthorized';
} elseif ($this->login === false) {
$this->authStatus = 'failed';
}

return false;
}

$this->authStatus = 'success';
return true;
}

Expand All @@ -23,12 +36,12 @@ public function getAuthMechanism()

public function getAuthStatus()
{
return 'success';
return $this->authStatus;
}

public function getUser()
{
return getenv($this->config['env_user_var']);
return $this->login;
}

public function getGroups()
Expand Down
2 changes: 1 addition & 1 deletion app/lib/munkireport/AuthLDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class AuthLDAP extends AbstractAuth
{
private $config, $groups, $login, $auth_status;
private $config, $groups, $login, $authStatus;

public function __construct($config)
{
Expand Down
2 changes: 2 additions & 0 deletions docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ Munkireport will **not** set the passphrase on the client through the install sc
- `SITENAME`: The site name which will appear in the title bar of your browser, Default: `MunkiReport`.
- `AUTH_METHODS`: A comma separated list of supported Authentication methods. Any combination of:
- `NOAUTH`: No authentication required
- `ENV`: Environment variable Authentication
- `LOCAL` : Local Users defined as .yml in the `users` folder
- `LDAP`: LDAP Authentication
- `AD`: Active Directory Authentication