/// <summary> /// Get all the teams that a particular service is open to /// </summary> /// <param name="endpoint">Endpoint for the service to look</param> /// <returns>List of string containing the team's username</returns> public List <string> GetAllowedConfigurationUsers(string endpoint) { return(_serviceManagementService.GetAllowedConfigurationUsers(endpoint)); }
static void Main(string[] args) { /////////////////// MAKING TOKENS ///////////////// //var jwtService = new JWTService(); //var token = jwtService.GenerateHmacSignedJWTToken("myClient", "read", Constants.Issuer, DateTime.Now.ToUniversalTime(), DateTime.Now.AddDays(10).ToUniversalTime(), // Constants.SigningKey); //// now we have string repre of token lets validate it //var handler = new JwtSecurityTokenHandler().ReadJwtToken(token); //var claims = handler.Claims.Where(x => x.Type == "aud").FirstOrDefault().Value; ////foreach (var item in claims) ////{ //// Console.WriteLine(item); ////} //Console.WriteLine(claims); //// create fake key. //Console.WriteLine(token); /////////////////////// TESTING TOKEN VALIDITY ///////////////////////// //var validationReq = new TokenValidationParameters(); //validationReq.IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("asdasds")); //validationReq.ValidAudience = "myClient"; //validationReq.ValidateAudience = true; //validationReq.ValidIssuer = Constants.Issuer; //validationReq.ValidateIssuerSigningKey = true; //validationReq.RequireSignedTokens = true; //validationReq.ValidateIssuer = true; //validationReq.ValidateLifetime = true; //Console.WriteLine(token); //var evilToken = token + "asdasd"; //var outToken = handler.ReadToken(token); //var result = handler.ValidateToken(token, validationReq, out outToken); //Console.WriteLine(result); //////////////////////// RANDOM TEST ///////////////// var sms = new ServiceManagementService(new ApiGatewayContext()); var usernames = sms.GetAllowedConfigurationUsers("panic"); //var teams = sms.GetTeamsUsername(); //foreach(var t in teams) //{ // Console.WriteLine(t); //} //var configjson = JsonSerializer.Deserialize<ServiceConfiguration>(config); // system.text using var _apiGatewayContext = new ApiGatewayContext(); var resource = "asdasda"; var scopeclaim = "jasonjason"; var owner = from team in _apiGatewayContext.Team join service in _apiGatewayContext.Service on team.ClientId equals service.Owner where resource == service.Endpoint && scopeclaim == team.Username select team.Username; var balh = "asdasd"; }