-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into VIH-10554-Demo-Change
- Loading branch information
Showing
253 changed files
with
14,322 additions
and
6,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,3 +349,4 @@ TESTS.xml | |
Coverage/ | ||
**/SpecFlow/userid | ||
.angular/ | ||
.nx/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace VideoWeb.Common.Configuration; | ||
|
||
public class RedisConfiguration | ||
{ | ||
public string Endpoint { get; set; } | ||
public string Password { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using LaunchDarkly.Logging; | ||
using LaunchDarkly.Sdk; | ||
using LaunchDarkly.Sdk.Server; | ||
using LaunchDarkly.Sdk.Server.Interfaces; | ||
|
||
namespace VideoWeb.Common; | ||
|
||
public interface IFeatureToggles | ||
{ | ||
public bool Vodafone(); | ||
} | ||
|
||
public class FeatureToggles : IFeatureToggles | ||
{ | ||
private readonly ILdClient _ldClient; | ||
private readonly Context _context; | ||
private const string LdUser = "vh-video-web"; | ||
private const string VodafoneToggleKey = "vodafone"; | ||
|
||
public FeatureToggles(string sdkKey, string environmentName) | ||
{ | ||
var config = LaunchDarkly.Sdk.Server.Configuration.Builder(sdkKey) | ||
.Logging(Components.Logging(Logs.ToWriter(Console.Out)).Level(LogLevel.Warn)).Build(); | ||
_context = Context.Builder(LdUser).Name(environmentName).Build(); | ||
_ldClient = new LdClient(config); | ||
} | ||
|
||
public bool Vodafone() | ||
{ | ||
return GetBoolValueWithKey(VodafoneToggleKey); | ||
} | ||
|
||
private bool GetBoolValueWithKey(string key) | ||
{ | ||
if (!_ldClient.Initialized) | ||
{ | ||
throw new InvalidOperationException("LaunchDarkly client not initialized"); | ||
} | ||
|
||
return _ldClient.BoolVariation(key, _context); | ||
} | ||
} | ||
|
14 changes: 1 addition & 13 deletions
14
VideoWeb/VideoWeb.Common/Security/HashGen/KinlyConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,6 @@ | ||
namespace VideoWeb.Common.Security.HashGen | ||
{ | ||
public class KinlyConfiguration | ||
public class KinlyConfiguration : SupplierConfiguration | ||
{ | ||
public string CallbackSecret { get; set; } | ||
public string Audience { get; set; } | ||
public string Issuer { get; set; } | ||
public string ApiSecret { get; set; } | ||
public string SelfTestApiSecret { get; set; } | ||
public int ExpiresInMinutes { get; set; } | ||
public int HashExpiresInMinutes { get; set; } | ||
public string JoinByPhoneFromDate { get; set; } | ||
public string TurnServer { get; set; } | ||
public string TurnServerUser { get; set; } | ||
public string TurnServerCredential { get; set; } | ||
public string HeartbeatUrlBase { get; set; } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
VideoWeb/VideoWeb.Common/Security/HashGen/SupplierConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace VideoWeb.Common.Security.HashGen | ||
{ | ||
public abstract class SupplierConfiguration | ||
{ | ||
public string CallbackSecret { get; set; } | ||
public string Audience { get; set; } | ||
public string Issuer { get; set; } | ||
public string ApiSecret { get; set; } | ||
public string SelfTestApiSecret { get; set; } | ||
public int ExpiresInMinutes { get; set; } | ||
public int HashExpiresInMinutes { get; set; } | ||
public string JoinByPhoneFromDate { get; set; } | ||
public string TurnServer { get; set; } | ||
public string TurnServerUser { get; set; } | ||
public string TurnServerCredential { get; set; } | ||
public string HeartbeatUrlBase { get; set; } | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
VideoWeb/VideoWeb.Common/Security/HashGen/VodafoneConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace VideoWeb.Common.Security.HashGen; | ||
|
||
public class VodafoneConfiguration : SupplierConfiguration | ||
{ | ||
} |
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
VideoWeb/VideoWeb.Common/Security/KinlyJwtTokenProvider.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using VideoWeb.Common.Security.HashGen; | ||
using VideoWeb.Common.Security.Tokens.Base; | ||
using VideoWeb.Common.Security.Tokens.Kinly; | ||
using VideoWeb.Common.Security.Tokens.Vodafone; | ||
|
||
namespace VideoWeb.Common.Security; | ||
|
||
public interface ISupplierLocator | ||
{ | ||
IJwtTokenProvider GetTokenProvider(); | ||
IOptions<SupplierConfiguration> GetSupplierConfiguration(); | ||
} | ||
|
||
public class SupplierLocator : ISupplierLocator | ||
{ | ||
private readonly IServiceProvider _serviceProvider; | ||
private readonly IOptions<KinlyConfiguration> _kinlyConfigOptions; | ||
private readonly IOptions<VodafoneConfiguration> _vodafoneConfigOptions; | ||
private readonly IFeatureToggles _featureToggles; | ||
|
||
public SupplierLocator(IServiceProvider serviceProvider, | ||
IFeatureToggles featureToggles, | ||
IOptions<KinlyConfiguration> kinlyConfigOptions, | ||
IOptions<VodafoneConfiguration> vodafoneConfigOptions) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
_featureToggles = featureToggles; | ||
_kinlyConfigOptions = kinlyConfigOptions; | ||
_vodafoneConfigOptions = vodafoneConfigOptions; | ||
} | ||
|
||
public IJwtTokenProvider GetTokenProvider() => _featureToggles.Vodafone() | ||
? _serviceProvider.GetService<IVodafoneJwtTokenProvider>() | ||
: _serviceProvider.GetService<IKinlyJwtTokenProvider>(); | ||
|
||
public IOptions<SupplierConfiguration> GetSupplierConfiguration() => | ||
_featureToggles.Vodafone() ? _vodafoneConfigOptions : _kinlyConfigOptions; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
VideoWeb/VideoWeb.Common/Security/Tokens/Base/IJwtTokenProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace VideoWeb.Common.Security.Tokens.Base; | ||
|
||
public interface IJwtTokenProvider | ||
{ | ||
string GenerateTokenForCallbackEndpoint(string claims, int expiresInMinutes); | ||
string GenerateToken(string claims, int expiresInMinutes); | ||
} |
46 changes: 46 additions & 0 deletions
46
VideoWeb/VideoWeb.Common/Security/Tokens/Base/JwtTokenProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.IdentityModel.Tokens.Jwt; | ||
using System.Security.Claims; | ||
using Microsoft.IdentityModel.Tokens; | ||
using VideoWeb.Common.Security.HashGen; | ||
|
||
namespace VideoWeb.Common.Security.Tokens.Base; | ||
|
||
public abstract class JwtTokenProvider : IJwtTokenProvider | ||
{ | ||
private readonly SupplierConfiguration _supplierConfiguration; | ||
|
||
protected JwtTokenProvider(SupplierConfiguration supplierConfiguration) | ||
{ | ||
_supplierConfiguration = supplierConfiguration; | ||
} | ||
|
||
public string GenerateTokenForCallbackEndpoint(string claims, int expiresInMinutes) | ||
{ | ||
var key = Convert.FromBase64String(_supplierConfiguration.CallbackSecret); | ||
return BuildToken(claims, expiresInMinutes, key); | ||
} | ||
|
||
public string GenerateToken(string claims, int expiresInMinutes) | ||
{ | ||
var key = Convert.FromBase64String(_supplierConfiguration.ApiSecret); | ||
return BuildToken(claims, expiresInMinutes, key); | ||
} | ||
|
||
private string BuildToken(string claims, int expiresInMinutes, byte[] key) | ||
{ | ||
var securityKey = new SymmetricSecurityKey(key); | ||
var descriptor = new SecurityTokenDescriptor | ||
{ | ||
Subject = new ClaimsIdentity(new[] {new Claim(ClaimTypes.Name, claims)}), | ||
NotBefore = DateTime.UtcNow.AddMinutes(-1), | ||
Issuer = _supplierConfiguration.Issuer, | ||
Expires = DateTime.UtcNow.AddMinutes(expiresInMinutes + 1), | ||
SigningCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha512) | ||
}; | ||
|
||
var handler = new JwtSecurityTokenHandler(); | ||
var token = handler.CreateJwtSecurityToken(descriptor); | ||
return handler.WriteToken(token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
VideoWeb/VideoWeb.Common/Security/Tokens/Kinly/IKinlyJwtTokenProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using VideoWeb.Common.Security.Tokens.Base; | ||
|
||
namespace VideoWeb.Common.Security.Tokens.Kinly; | ||
|
||
public interface IKinlyJwtTokenProvider : IJwtTokenProvider | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
VideoWeb/VideoWeb.Common/Security/Tokens/Kinly/KinlyJwtTokenProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using VideoWeb.Common.Security.HashGen; | ||
using VideoWeb.Common.Security.Tokens.Base; | ||
|
||
namespace VideoWeb.Common.Security.Tokens.Kinly; | ||
|
||
public class KinlyJwtTokenProvider : JwtTokenProvider, IKinlyJwtTokenProvider | ||
{ | ||
public KinlyJwtTokenProvider(KinlyConfiguration supplierConfiguration) : base(supplierConfiguration) | ||
{ | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
VideoWeb/VideoWeb.Common/Security/Tokens/Vodafone/IVodafoneJwtTokenProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using VideoWeb.Common.Security.Tokens.Base; | ||
|
||
namespace VideoWeb.Common.Security.Tokens.Vodafone; | ||
|
||
public interface IVodafoneJwtTokenProvider : IJwtTokenProvider | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
VideoWeb/VideoWeb.Common/Security/Tokens/Vodafone/VodafoneJwtTokenProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using VideoWeb.Common.Security.HashGen; | ||
using VideoWeb.Common.Security.Tokens.Base; | ||
|
||
namespace VideoWeb.Common.Security.Tokens.Vodafone; | ||
|
||
public class VodafoneJwtTokenProvider : JwtTokenProvider, IVodafoneJwtTokenProvider | ||
{ | ||
public VodafoneJwtTokenProvider(VodafoneConfiguration vodafoneConfiguration) : base(vodafoneConfiguration) | ||
{ | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.