CrazyIter_Bin 3 年之前
父节点
当前提交
d79e58b6a6

+ 13 - 3
TEAMModelOS.SDK/Context/Attributes/Filter/ApiTokenAttribute.cs

@@ -162,14 +162,25 @@ namespace TEAMModelOS.Filter
                                         if (!string.IsNullOrWhiteSpace(XAuthSchool))
                                         {
                                             var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOpenApi");
-                                            List<BusinessSchool> schools =   table.FindListByDictSync<BusinessSchool>(new Dictionary<string, object> { { "PartitionKey", $"BusinessSchool-{id}" } });
+                                            List<BusinessSchool> schools =   table.FindListByDictSync<BusinessSchool>(new Dictionary<string, object> { { "PartitionKey", $"BusinessSchool-{id}" } ,{ "RowKey",XAuthSchool } });
+                                            List<BusinessConfig> configs = table.FindListByDictSync<BusinessConfig>(new Dictionary<string, object> { { "PartitionKey", $"BusinessConfig" }, { "RowKey", id } });
+                                            //同时授权学校存在,且jti一致 ,验证jti原因在于 token轮换或刷新后,旧的token不能再使用。
+                                            if (schools.Any() && configs.Any())
+                                            {
+                                                if (configs[0].jti.Equals(jti)) {
+                                                    pass = true;
+                                                    school = XAuthSchool;
+                                                }
+                                            }
+                                            else {
+                                                pass = false;
+                                            }
                                         }
                                         else
                                         {
                                             pass = false;
                                         }
                                     }
-                                    
                                 }
                                 if (!string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(school) && !string.IsNullOrEmpty(jti))
                                 {
@@ -180,7 +191,6 @@ namespace TEAMModelOS.Filter
                                 }
                             }
                         }
-                        
                     }
                     if (pass)
                     {

+ 1 - 0
TEAMModelOS.SDK/Models/Table/BusinessConfig.cs

@@ -48,5 +48,6 @@ namespace TEAMModelOS.SDK.Models.Table
         /// 授权的token ,存放 scope="business",Sub="合作方id",  9e40e436-f958-498d-93cf-4242b77a17ab
         /// </summary>
         public string token { get; set; }
+        public string jti { get; set; }
     }
 }