1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-16 08:13:20 +00:00

identity server client for auth

This commit is contained in:
Kyle Spearrin
2017-05-06 20:20:57 -04:00
parent 7117f00480
commit d1cf6c68f3
15 changed files with 84 additions and 23 deletions

View File

@@ -1,7 +1,6 @@
using System;
using Bit.App.Abstractions;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Bit.App.Services
@@ -77,6 +76,20 @@ namespace Bit.App.Services
}
}
public string TokenIssuer
{
get
{
var decoded = DecodeToken();
if(decoded?["iss"] == null)
{
throw new InvalidOperationException("No issuer in token.");
}
return decoded?["iss"].Value<string>();
}
}
public bool TokenExpired => DateTime.UtcNow < TokenExpiration;
public TimeSpan TokenTimeRemaining => TokenExpiration - DateTime.UtcNow;
public bool TokenNeedsRefresh => TokenTimeRemaining.TotalMinutes < 5;