Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Administrator
Titanium-Web-Proxy
Commits
6b532c77
Commit
6b532c77
authored
May 23, 2017
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
3a82ab2a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
15 deletions
+45
-15
RunTime.cs
Titanium.Web.Proxy/Helpers/RunTime.cs
+3
-1
State.cs
Titanium.Web.Proxy/Network/WinAuth/Security/State.cs
+2
-7
WinAuthEndPoint.cs
...ium.Web.Proxy/Network/WinAuth/Security/WinAuthEndPoint.cs
+28
-2
WinAuthHandler.cs
Titanium.Web.Proxy/Network/WinAuth/WinAuthHandler.cs
+2
-2
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+6
-0
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+3
-2
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+1
-1
No files found.
Titanium.Web.Proxy/Helpers/RunTime.cs
View file @
6b532c77
...
...
@@ -7,13 +7,15 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
internal
class
RunTime
{
private
static
Lazy
<
bool
>
isMonoRuntime
=
new
Lazy
<
bool
>(()=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
/// <summary>
/// Checks if current run time is Mono
/// </summary>
/// <returns></returns>
internal
static
bool
IsRunningOnMono
()
{
return
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
;
return
isMonoRuntime
.
Value
;
}
}
}
Titanium.Web.Proxy/Network/WinAuth/Security/State.cs
View file @
6b532c77
...
...
@@ -12,7 +12,7 @@
this
.
Credentials
=
new
Common
.
SecurityHandle
(
0
);
this
.
Context
=
new
Common
.
SecurityHandle
(
0
);
this
.
LastSeen
=
DateTime
.
MinValue
;
this
.
LastSeen
=
DateTime
.
Now
;
}
/// <summary>
...
...
@@ -30,11 +30,6 @@
/// </summary>
internal
DateTime
LastSeen
;
internal
bool
isOlder
(
int
seconds
)
{
return
(
this
.
LastSeen
.
AddSeconds
(
seconds
)
<
DateTime
.
UtcNow
)
?
true
:
false
;
}
internal
void
ResetHandles
()
{
this
.
Credentials
.
Reset
();
...
...
@@ -43,7 +38,7 @@
internal
void
UpdatePresence
()
{
this
.
LastSeen
=
DateTime
.
Utc
Now
;
this
.
LastSeen
=
DateTime
.
Now
;
}
}
}
Titanium.Web.Proxy/Network/WinAuth/Security/EndPoint.cs
→
Titanium.Web.Proxy/Network/WinAuth/Security/
WinAuth
EndPoint.cs
View file @
6b532c77
...
...
@@ -3,13 +3,15 @@
namespace
Titanium.Web.Proxy.Network.WinAuth.Security
{
using
System
;
using
System.Linq
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Runtime.InteropServices
;
using
System.Security.Principal
;
using
static
Common
;
using
System.Threading.Tasks
;
internal
class
EndPoint
internal
class
WinAuth
EndPoint
{
/// <summary>
/// Keep track of auth states for reuse in final challenge response
...
...
@@ -117,6 +119,8 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
var
state
=
authStates
[
requestId
];
state
.
UpdatePresence
();
result
=
InitializeSecurityContext
(
ref
state
.
Credentials
,
ref
state
.
Context
,
hostname
,
...
...
@@ -136,7 +140,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
// Client challenge issue operation failed.
return
null
;
}
authStates
.
Remove
(
requestId
);
token
=
clientToken
.
GetBytes
();
}
...
...
@@ -148,6 +152,28 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
return
token
;
}
/// <summary>
/// Clear any hanging states
/// </summary>
/// <param name="stateCacheTimeOutMinutes"></param>
internal
static
async
void
ClearIdleStates
(
int
stateCacheTimeOutMinutes
)
{
var
cutOff
=
DateTime
.
Now
.
AddMinutes
(-
1
*
stateCacheTimeOutMinutes
);
var
outdated
=
authStates
.
Where
(
x
=>
x
.
Value
.
LastSeen
<
cutOff
)
.
ToList
();
foreach
(
var
cache
in
outdated
)
{
authStates
.
Remove
(
cache
.
Key
);
}
//after a minute come back to check for outdated certificates in cache
await
Task
.
Delay
(
1000
*
60
);
}
#
region
Native
calls
to
secur32
.
dll
[
DllImport
(
"secur32.dll"
,
SetLastError
=
true
)]
...
...
Titanium.Web.Proxy/Network/WinAuth/WinAuthHandler.cs
View file @
6b532c77
...
...
@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth
public
static
string
GetInitialAuthToken
(
string
serverHostname
,
string
authScheme
,
Guid
requestId
)
{
var
tokenBytes
=
EndPoint
.
AcquireInitialSecurityToken
(
serverHostname
,
authScheme
,
requestId
);
var
tokenBytes
=
WinAuth
EndPoint
.
AcquireInitialSecurityToken
(
serverHostname
,
authScheme
,
requestId
);
return
string
.
Concat
(
" "
,
Convert
.
ToBase64String
(
tokenBytes
));
}
...
...
@@ -36,7 +36,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth
public
static
string
GetFinalAuthToken
(
string
serverHostname
,
string
serverToken
,
Guid
requestId
)
{
var
tokenBytes
=
EndPoint
.
AcquireFinalSecurityToken
(
serverHostname
,
var
tokenBytes
=
WinAuth
EndPoint
.
AcquireFinalSecurityToken
(
serverHostname
,
Convert
.
FromBase64String
(
serverToken
),
requestId
);
return
string
.
Concat
(
" "
,
Convert
.
ToBase64String
(
tokenBytes
));
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
6b532c77
...
...
@@ -12,6 +12,7 @@ using Titanium.Web.Proxy.Helpers;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
Titanium.Web.Proxy.Network.WinAuth.Security
;
namespace
Titanium.Web.Proxy
{
...
...
@@ -475,6 +476,11 @@ namespace Titanium.Web.Proxy
CertificateManager
.
ClearIdleCertificates
(
CertificateCacheTimeOutMinutes
);
if
(!
RunTime
.
IsRunningOnMono
())
{
WinAuthEndPoint
.
ClearIdleStates
(
2
);
}
proxyRunning
=
true
;
}
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
6b532c77
...
...
@@ -37,8 +37,9 @@ namespace Titanium.Web.Proxy
}
//check for windows authentication
if
(
EnableWinAuth
&&
args
.
WebSession
.
Response
.
ResponseStatusCode
==
"401"
)
if
(
EnableWinAuth
&&
args
.
WebSession
.
Response
.
ResponseStatusCode
==
"401"
&&
!
RunTime
.
IsRunningOnMono
())
{
var
disposed
=
await
Handle401UnAuthorized
(
args
);
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
6b532c77
...
...
@@ -108,7 +108,7 @@
<Compile
Include=
"Http\HttpWebClient.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\BufferWrapper.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\Common.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\EndPoint.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\
WinAuth
EndPoint.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\LittleEndian.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\Message.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\State.cs"
/>
...
...
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