应用License定义及授权

更新时间: 2022-11-17 10:02:14

用户定义应用License

应用License定义入口为:产品列表-产品详情-产品版本操作中的“License定义”。

imageimage

在用户应用中编写应用license代码

示例代码如下:

type LicenseInfo struct {
	Status     string                 `json:"status,omitempty"`
	ExpireTime string                 `json:"expireTime,omitempty"`
	Info       map[string]interface{} `json:"info,omitempty"`
	Message    string                 `json:"message,omitempty"`
}

func main() {
	r := gin.Default()
	r.GET("/license", func(c *gin.Context) {
		//域名&Path: license-server.acs-system:9527/license-info?name=${application name}&namespace=${application namespace}
		url:="http://license-server.acs-system.svc.cluster.local:9527/license-info?name=license-test&namespace=license-test"
		res,err :=http.Get(url)
		if err!=nil{
			c.String(http.StatusInternalServerError, "get application license failed %v\n",err)
		}
		defer res.Body.Close()
		body,err := ioutil.ReadAll(res.Body)
		if err!=nil{
			c.String(http.StatusInternalServerError, "get application license read body err %v\n",err)
		}
		logrus.Printf("body is %s\n",string(body))
		var licenseInfo *LicenseInfo
		if err := json.Unmarshal(body, &licenseInfo); err != nil {
			c.String(http.StatusInternalServerError, "failed to unmarshal body err %v\n",err)
		}
		//用户可以拿到licenseInfo对象,这里输出展示
		c.String(http.StatusOK, "license info is  %v\n",licenseInfo)
	})
	r.Run(":8009")
}

在验证环境中使用应用license测试

验证环境会自动申请应用的试用版license,adp平台成功部署应用后,应用就可以向operator发出请求,获取需要的license信息。

image

在应用中获取license定义

image

License应用授权申请

如果产品配置过应用license定义,则可以在局点交付-授权管理 的授权列表中找到该产品的License授权入口。

(注意:在申请产品的应用license授权前,需要先申请底座license,且产品的授权类型需和底座一致,例如底座申请了试用版的license,则产品的应用license也只能申请试用版。)

image

如果该产品由本人创建,本人使用,则申请后即为已授权;如果产品版本授权给其他用户,由其他用户申请应用license,则该申请需要产品创建人审批。

image

产品创建者可以在首页快速入口-授权审批入口找到需要审批的项目。

image

审批后,被授权者的license授权列表中该产品状态即为已授权。

image
阿里云首页 云原生应用交付平台 相关技术圈