Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
58ab1e61
Commit
58ab1e61
authored
Dec 01, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(proxy) hook in new auth factory
parent
64c433d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
15 deletions
+40
-15
squid.auth-user.php
src/etc/inc/squid.auth-user.php
+35
-8
main.xml
...pnsense/mvc/app/controllers/OPNsense/Proxy/forms/main.xml
+2
-1
Proxy.xml
src/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml
+3
-6
No files found.
src/etc/inc/squid.auth-user.php
View file @
58ab1e61
...
...
@@ -33,21 +33,48 @@ require_once("auth.inc");
openlog
(
"squid"
,
LOG_ODELAY
,
LOG_AUTH
);
$authFactory
=
new
\OPNsense\Auth\AuthenticationFactory
();
$f
=
fopen
(
"php://stdin"
,
"r"
);
while
(
$line
=
fgets
(
$f
))
{
$fields
=
explode
(
' '
,
trim
(
$line
));
$username
=
rawurldecode
(
$fields
[
0
]);
$password
=
rawurldecode
(
$fields
[
1
]);
if
(
authenticate_user
(
$username
,
$password
))
{
$user
=
getUserEntry
(
$username
);
if
(
is_array
(
$user
)
&&
userHasPrivilege
(
$user
,
"user-proxy-auth"
))
{
syslog
(
LOG_NOTICE
,
"user '
{
$username
}
' authenticated
\n
"
);
fwrite
(
STDOUT
,
"OK
\n
"
);
}
else
{
syslog
(
LOG_WARNING
,
"user '
{
$username
}
' cannot authenticate for squid because of missing user-proxy-auth role"
);
fwrite
(
STDOUT
,
"ERR
\n
"
);
$isAuthenticated
=
false
;
if
(
isset
(
$config
[
'OPNsense'
][
'proxy'
][
'forward'
][
'authentication'
][
'method'
]))
{
foreach
(
explode
(
','
,
$config
[
'OPNsense'
][
'proxy'
][
'forward'
][
'authentication'
][
'method'
])
as
$authServerName
)
{
$authServer
=
$authFactory
->
get
(
trim
(
$authServerName
));
if
(
$authsrv
==
null
)
{
// authenticator not found, use local
$authServer
=
$authFactory
->
get
(
'Local Database'
);
}
$isAuthenticated
=
$authServer
->
authenticate
(
$username
,
$password
);
if
(
$isAuthenticated
)
{
if
(
get_class
(
$authServer
)
==
"OPNsense\Auth\Local"
)
{
// todo: user priv check needs a reload of squid, maybe it's better to move the token check to
// the auth object.
//
// when using local authentication, check if user has role user-proxy-auth
$user
=
getUserEntry
(
$username
);
if
(
is_array
(
$user
)
&&
userHasPrivilege
(
$user
,
"user-proxy-auth"
))
{
break
;
}
else
{
// log user auth failure
syslog
(
LOG_WARNING
,
"user '
{
$username
}
' cannot authenticate for squid because of missing user-proxy-auth role"
);
fwrite
(
STDOUT
,
"ERR
\n
"
);
$isAuthenticated
=
false
;
}
}
else
{
break
;
}
}
}
}
if
(
$isAuthenticated
)
{
syslog
(
LOG_NOTICE
,
"user '
{
$username
}
' authenticated
\n
"
);
fwrite
(
STDOUT
,
"OK
\n
"
);
}
else
{
syslog
(
LOG_WARNING
,
"user '
{
$username
}
' could not authenticate.
\n
"
);
fwrite
(
STDOUT
,
"ERR
\n
"
);
...
...
src/opnsense/mvc/app/controllers/OPNsense/Proxy/forms/main.xml
View file @
58ab1e61
...
...
@@ -339,7 +339,8 @@
<field>
<id>
proxy.forward.authentication.method
</id>
<label>
Authentication method
</label>
<type>
dropdown
</type>
<type>
select_multiple
</type>
<style>
tokenize
</style>
<help>
<![CDATA[Select Authentication method]]>
</help>
</field>
<field>
...
...
src/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml
View file @
58ab1e61
...
...
@@ -247,13 +247,10 @@
</remoteACLs>
</acl>
<authentication>
<method
type=
"OptionField"
>
<default>
none
</default>
<method
type=
"AuthenticationServerField"
>
<Required>
N
</Required>
<OptionValues>
<none>
No Authentication
</none>
<local>
Local User Authentication
</local>
</OptionValues>
<multiple>
Y
</multiple>
<default>
Local Database
</default>
</method>
<realm
type=
"TextField"
>
<default>
OPNsense proxy authentication
</default>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment