|
@@ -0,0 +1,40 @@
|
|
|
+package com.qmth.ops.api.security;
|
|
|
+
|
|
|
+import com.qmth.boot.core.security.annotation.AuthorizationComponent;
|
|
|
+import com.qmth.boot.core.security.model.AccessEntity;
|
|
|
+import com.qmth.boot.core.security.service.AuthorizationService;
|
|
|
+import com.qmth.boot.core.sms.model.SmsConstants;
|
|
|
+import com.qmth.boot.tools.signature.SignatureType;
|
|
|
+import com.qmth.ops.api.constants.OpsApiConstants;
|
|
|
+import com.qmth.ops.biz.domain.Deploy;
|
|
|
+import com.qmth.ops.biz.domain.Org;
|
|
|
+import com.qmth.ops.biz.service.DeployService;
|
|
|
+import com.qmth.ops.biz.service.OrgService;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+@AuthorizationComponent(prefix = SmsConstants.API_PATH_PREFIX, type = SignatureType.SECRET)
|
|
|
+public class SmsAuthorizationService implements AuthorizationService<AccessEntity>, OpsApiConstants {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeployService deployService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OrgService orgService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AccessEntity findByIdentity(String identity, SignatureType signatureType, String path) {
|
|
|
+ Deploy deploy = deployService.findByAccessKey(identity);
|
|
|
+ if (deploy != null) {
|
|
|
+ if (deploy.getControl() != null && !deploy.getControl().hasExpired()) {
|
|
|
+ return new AccessDeploy(deploy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Org org = orgService.findByAccessKey(identity);
|
|
|
+ if (org != null && org.isEnable()) {
|
|
|
+ return new AccessOrg(org);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|