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
a940f69d
Commit
a940f69d
authored
May 23, 2017
by
justcoding121
Committed by
justcoding121
May 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
d10bb71a
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 @
a940f69d
...
@@ -7,13 +7,15 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -7,13 +7,15 @@ namespace Titanium.Web.Proxy.Helpers
/// </summary>
/// </summary>
internal
class
RunTime
internal
class
RunTime
{
{
private
static
Lazy
<
bool
>
isMonoRuntime
=
new
Lazy
<
bool
>(()=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
/// <summary>
/// <summary>
/// Checks if current run time is Mono
/// Checks if current run time is Mono
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
internal
static
bool
IsRunningOnMono
()
internal
static
bool
IsRunningOnMono
()
{
{
return
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
;
return
isMonoRuntime
.
Value
;
}
}
}
}
}
}
Titanium.Web.Proxy/Network/WinAuth/Security/State.cs
View file @
a940f69d
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
this
.
Credentials
=
new
Common
.
SecurityHandle
(
0
);
this
.
Credentials
=
new
Common
.
SecurityHandle
(
0
);
this
.
Context
=
new
Common
.
SecurityHandle
(
0
);
this
.
Context
=
new
Common
.
SecurityHandle
(
0
);
this
.
LastSeen
=
DateTime
.
MinValue
;
this
.
LastSeen
=
DateTime
.
Now
;
}
}
/// <summary>
/// <summary>
...
@@ -30,11 +30,6 @@
...
@@ -30,11 +30,6 @@
/// </summary>
/// </summary>
internal
DateTime
LastSeen
;
internal
DateTime
LastSeen
;
internal
bool
isOlder
(
int
seconds
)
{
return
(
this
.
LastSeen
.
AddSeconds
(
seconds
)
<
DateTime
.
UtcNow
)
?
true
:
false
;
}
internal
void
ResetHandles
()
internal
void
ResetHandles
()
{
{
this
.
Credentials
.
Reset
();
this
.
Credentials
.
Reset
();
...
@@ -43,7 +38,7 @@
...
@@ -43,7 +38,7 @@
internal
void
UpdatePresence
()
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 @
a940f69d
...
@@ -3,13 +3,15 @@
...
@@ -3,13 +3,15 @@
namespace
Titanium.Web.Proxy.Network.WinAuth.Security
namespace
Titanium.Web.Proxy.Network.WinAuth.Security
{
{
using
System
;
using
System
;
using
System.Linq
;
using
System.Collections.Concurrent
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Security.Principal
;
using
System.Security.Principal
;
using
static
Common
;
using
static
Common
;
using
System.Threading.Tasks
;
internal
class
EndPoint
internal
class
WinAuth
EndPoint
{
{
/// <summary>
/// <summary>
/// Keep track of auth states for reuse in final challenge response
/// Keep track of auth states for reuse in final challenge response
...
@@ -117,6 +119,8 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -117,6 +119,8 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
var
state
=
authStates
[
requestId
];
var
state
=
authStates
[
requestId
];
state
.
UpdatePresence
();
result
=
InitializeSecurityContext
(
ref
state
.
Credentials
,
result
=
InitializeSecurityContext
(
ref
state
.
Credentials
,
ref
state
.
Context
,
ref
state
.
Context
,
hostname
,
hostname
,
...
@@ -136,7 +140,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -136,7 +140,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
// Client challenge issue operation failed.
// Client challenge issue operation failed.
return
null
;
return
null
;
}
}
authStates
.
Remove
(
requestId
);
authStates
.
Remove
(
requestId
);
token
=
clientToken
.
GetBytes
();
token
=
clientToken
.
GetBytes
();
}
}
...
@@ -148,6 +152,28 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
...
@@ -148,6 +152,28 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
return
token
;
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
#
region
Native
calls
to
secur32
.
dll
[
DllImport
(
"secur32.dll"
,
SetLastError
=
true
)]
[
DllImport
(
"secur32.dll"
,
SetLastError
=
true
)]
...
...
Titanium.Web.Proxy/Network/WinAuth/WinAuthHandler.cs
View file @
a940f69d
...
@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth
...
@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth
public
static
string
GetInitialAuthToken
(
string
serverHostname
,
public
static
string
GetInitialAuthToken
(
string
serverHostname
,
string
authScheme
,
Guid
requestId
)
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
));
return
string
.
Concat
(
" "
,
Convert
.
ToBase64String
(
tokenBytes
));
}
}
...
@@ -36,7 +36,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth
...
@@ -36,7 +36,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth
public
static
string
GetFinalAuthToken
(
string
serverHostname
,
public
static
string
GetFinalAuthToken
(
string
serverHostname
,
string
serverToken
,
Guid
requestId
)
string
serverToken
,
Guid
requestId
)
{
{
var
tokenBytes
=
EndPoint
.
AcquireFinalSecurityToken
(
serverHostname
,
var
tokenBytes
=
WinAuth
EndPoint
.
AcquireFinalSecurityToken
(
serverHostname
,
Convert
.
FromBase64String
(
serverToken
),
requestId
);
Convert
.
FromBase64String
(
serverToken
),
requestId
);
return
string
.
Concat
(
" "
,
Convert
.
ToBase64String
(
tokenBytes
));
return
string
.
Concat
(
" "
,
Convert
.
ToBase64String
(
tokenBytes
));
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
a940f69d
...
@@ -12,6 +12,7 @@ using Titanium.Web.Proxy.Helpers;
...
@@ -12,6 +12,7 @@ using Titanium.Web.Proxy.Helpers;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
Titanium.Web.Proxy.Network.WinAuth.Security
;
namespace
Titanium.Web.Proxy
namespace
Titanium.Web.Proxy
{
{
...
@@ -475,6 +476,11 @@ namespace Titanium.Web.Proxy
...
@@ -475,6 +476,11 @@ namespace Titanium.Web.Proxy
CertificateManager
.
ClearIdleCertificates
(
CertificateCacheTimeOutMinutes
);
CertificateManager
.
ClearIdleCertificates
(
CertificateCacheTimeOutMinutes
);
if
(!
RunTime
.
IsRunningOnMono
())
{
WinAuthEndPoint
.
ClearIdleStates
(
2
);
}
proxyRunning
=
true
;
proxyRunning
=
true
;
}
}
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
a940f69d
...
@@ -37,8 +37,9 @@ namespace Titanium.Web.Proxy
...
@@ -37,8 +37,9 @@ namespace Titanium.Web.Proxy
}
}
//check for windows authentication
//check for windows authentication
if
(
EnableWinAuth
&&
if
(
EnableWinAuth
&&
args
.
WebSession
.
Response
.
ResponseStatusCode
==
"401"
)
args
.
WebSession
.
Response
.
ResponseStatusCode
==
"401"
&&
!
RunTime
.
IsRunningOnMono
())
{
{
var
disposed
=
await
Handle401UnAuthorized
(
args
);
var
disposed
=
await
Handle401UnAuthorized
(
args
);
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
a940f69d
...
@@ -108,7 +108,7 @@
...
@@ -108,7 +108,7 @@
<Compile
Include=
"Http\HttpWebClient.cs"
/>
<Compile
Include=
"Http\HttpWebClient.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\BufferWrapper.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\BufferWrapper.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\Common.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\LittleEndian.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\Message.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\Message.cs"
/>
<Compile
Include=
"Network\WinAuth\Security\State.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