aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Web/Security
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-02-24 13:38:47 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-02-24 13:38:47 +0200
commit64b768178dc9e64293a52c1b6d2631709af9502a (patch)
tree6b7782fdbbbab4f734a1cb499cca03728c4f8f69 /Software/Visual_Studio/Tango.Web/Security
parent028ab0e5cc2699ceec3e04b1eeab5f56b9b38083 (diff)
downloadTango-64b768178dc9e64293a52c1b6d2631709af9502a.tar.gz
Tango-64b768178dc9e64293a52c1b6d2631709af9502a.zip
Removed all refresh tokens use :/
Diffstat (limited to 'Software/Visual_Studio/Tango.Web/Security')
-rw-r--r--Software/Visual_Studio/Tango.Web/Security/RefreshTokenEntity.cs24
-rw-r--r--Software/Visual_Studio/Tango.Web/Security/RenewTokenRequest.cs14
-rw-r--r--Software/Visual_Studio/Tango.Web/Security/RenewTokenResponse.cs14
-rw-r--r--Software/Visual_Studio/Tango.Web/Security/WebToken.cs34
-rw-r--r--Software/Visual_Studio/Tango.Web/Security/WebTokenResponse.cs1
5 files changed, 24 insertions, 63 deletions
diff --git a/Software/Visual_Studio/Tango.Web/Security/RefreshTokenEntity.cs b/Software/Visual_Studio/Tango.Web/Security/RefreshTokenEntity.cs
deleted file mode 100644
index 839027ca1..000000000
--- a/Software/Visual_Studio/Tango.Web/Security/RefreshTokenEntity.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using Microsoft.WindowsAzure.Storage.Table;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tango.Web.Security
-{
- public class RefreshTokenEntity : TableEntity
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="RefreshTokenEntity"/> class.
- /// </summary>
- public RefreshTokenEntity()
- {
-
- }
-
- public String RefreshToken { get; set; }
- public String AccessToken { get; set; }
- public DateTime Expiration { get; set; }
- }
-}
diff --git a/Software/Visual_Studio/Tango.Web/Security/RenewTokenRequest.cs b/Software/Visual_Studio/Tango.Web/Security/RenewTokenRequest.cs
deleted file mode 100644
index 213cd3afd..000000000
--- a/Software/Visual_Studio/Tango.Web/Security/RenewTokenRequest.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Transport.Web;
-
-namespace Tango.Web.Security
-{
- public class RenewTokenRequest : WebRequestMessage
- {
- public String RefreshToken { get; set; }
- }
-}
diff --git a/Software/Visual_Studio/Tango.Web/Security/RenewTokenResponse.cs b/Software/Visual_Studio/Tango.Web/Security/RenewTokenResponse.cs
deleted file mode 100644
index 76c381852..000000000
--- a/Software/Visual_Studio/Tango.Web/Security/RenewTokenResponse.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Transport.Web;
-
-namespace Tango.Web.Security
-{
- public class RenewTokenResponse : WebTokenResponse
- {
-
- }
-}
diff --git a/Software/Visual_Studio/Tango.Web/Security/WebToken.cs b/Software/Visual_Studio/Tango.Web/Security/WebToken.cs
index 006ed9de7..7aa4860ab 100644
--- a/Software/Visual_Studio/Tango.Web/Security/WebToken.cs
+++ b/Software/Visual_Studio/Tango.Web/Security/WebToken.cs
@@ -38,12 +38,15 @@ namespace Tango.Web.Security
builder = builder.ExpirationTime(expiration.Value);
}
+ String refreshToken = Guid.NewGuid().ToString();
+
builder = builder.AddClaim("object", null);
+ builder = builder.AddClaim("refresh-token", refreshToken);
return new WebToken()
{
AccessToken = builder.Build(),
- RefreshToken = Guid.NewGuid().ToString(),
+ RefreshToken = refreshToken,
Expiration = expiration,
Issued = issued,
};
@@ -65,11 +68,10 @@ namespace Tango.Web.Security
.Decode(AccessToken);
}
- public WebToken Renew(String secret, String token)
+ public WebToken Renew(String secret)
{
- WebToken webToken = WebToken.FromToken(token);
- var newToken = CreateNew(secret, DateTime.UtcNow.Add(webToken.Expiration.Value - webToken.Issued));
- newToken.RefreshToken = webToken.RefreshToken;
+ var newToken = CreateNew(secret, DateTime.UtcNow.Add(Expiration.Value - Issued));
+ newToken.RefreshToken = RefreshToken;
return newToken;
}
@@ -95,6 +97,11 @@ namespace Tango.Web.Security
webToken.Issued = ConvertEpochToDateTime(iat);
}
+ if (payload.ContainsKey("refresh-token"))
+ {
+ webToken.RefreshToken = payload["refresh-token"].ToString();
+ }
+
return webToken;
}
@@ -128,12 +135,15 @@ namespace Tango.Web.Security
builder = builder.ExpirationTime(expiration.Value);
}
+ String refreshToken = Guid.NewGuid().ToString();
+
builder = builder.AddClaim("object", obj);
+ builder = builder.AddClaim("refresh-token", refreshToken);
return new WebToken<T>()
{
AccessToken = builder.Build(),
- RefreshToken = Guid.NewGuid().ToString(),
+ RefreshToken = refreshToken,
Expiration = expiration,
Issued = issued,
Object = obj,
@@ -162,16 +172,20 @@ namespace Tango.Web.Security
webToken.Issued = ConvertEpochToDateTime(iat);
}
+ if (payload.ContainsKey("refresh-token"))
+ {
+ webToken.RefreshToken = payload["refresh-token"].ToString();
+ }
+
webToken.Object = JsonConvert.DeserializeObject<T>(payload["object"].ToString());
return webToken;
}
- public new WebToken<T> Renew(String secret, String token)
+ public new WebToken<T> Renew(String secret)
{
- WebToken<T> webToken = WebToken<T>.FromToken(token);
- var newToken = WebToken<T>.CreateNew(secret, webToken.Object, DateTime.UtcNow.Add(webToken.Expiration.Value - webToken.Issued));
- newToken.RefreshToken = webToken.RefreshToken;
+ var newToken = WebToken<T>.CreateNew(secret, Object, DateTime.UtcNow.Add(Expiration.Value - Issued));
+ newToken.RefreshToken = RefreshToken;
return newToken;
}
}
diff --git a/Software/Visual_Studio/Tango.Web/Security/WebTokenResponse.cs b/Software/Visual_Studio/Tango.Web/Security/WebTokenResponse.cs
index 8c8f2f096..e68305fbb 100644
--- a/Software/Visual_Studio/Tango.Web/Security/WebTokenResponse.cs
+++ b/Software/Visual_Studio/Tango.Web/Security/WebTokenResponse.cs
@@ -10,6 +10,5 @@ namespace Tango.Web.Security
public class WebTokenResponse : WebResponseMessage
{
public String AccessToken { get; set; }
- public String RefreshToken { get; set; }
}
}