This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 6262
6363 'login_attribute ' => 'samaccountname ' ,
6464
65+ /*
66+ |--------------------------------------------------------------------------
67+ | Windows Auth Attribute (SSO)
68+ |--------------------------------------------------------------------------
69+ |
70+ | The windows authentication attribute is the name of the server variable
71+ | that is filled when SSO authentication is performed.
72+ |
73+ | This is only used in conjunction with the Adldap\Laravel\Middleware\WindowsAuthenticate
74+ | middleware.
75+ |
76+ | If your using Windows authentication this attribute must be named `AUTH_USER`.
77+ |
78+ | If your using Apache, this attribute must be named `REMOTE_USER`.
79+ |
80+ */
81+
82+ 'windows_auth_attribute ' => 'AUTH_USER ' ,
83+
6584 /*
6685 |--------------------------------------------------------------------------
6786 | Bind User to Model
Original file line number Diff line number Diff line change 88use Illuminate \Contracts \Auth \Guard ;
99use Illuminate \Database \Eloquent \Model ;
1010use Illuminate \Http \Request ;
11+ use Illuminate \Support \Facades \Config ;
1112
1213class WindowsAuthenticate
1314{
@@ -40,8 +41,11 @@ public function __construct(Guard $auth)
4041 */
4142 public function handle (Request $ request , Closure $ next )
4243 {
44+ // Retrieve the SSO login attribute.
45+ $ auth = $ this ->getWindowsAuthAttribute ();
46+
4347 // Handle Windows Authentication.
44- if ($ account = $ request ->server (' AUTH_USER ' )) {
48+ if ($ account = $ request ->server ($ auth )) {
4549 // Usernames will be prefixed with their domain,
4650 // we just need their account name.
4751 list ($ domain , $ username ) = explode ('\\' , $ account );
@@ -83,4 +87,14 @@ public function createModel()
8387 {
8488 $ this ->auth ->model ();
8589 }
90+
91+ /**
92+ * Returns the windows authentication attribute.
93+ *
94+ * @return string
95+ */
96+ protected function getWindowsAuthAttribute ()
97+ {
98+ return Config::get ('adldap_auth.windows_auth_attribute ' , 'AUTH_USER ' );
99+ }
86100}
You can’t perform that action at this time.
0 commit comments