优化访问控制,将“认证”两字改为“鉴权”

This commit is contained in:
GoEdgeLab
2022-08-30 11:22:54 +08:00
parent ba0ae51592
commit 977c89f9e1
22 changed files with 756 additions and 77 deletions

View File

@@ -1,6 +1,6 @@
{$layout "layout_popup"}
<h3>创建认证方式</h3>
<h3>创建鉴权方式</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
@@ -12,16 +12,118 @@
</td>
</tr>
<tr>
<td>认证类型 *</td>
<td>鉴权类型 *</td>
<td>
<select class="ui dropdown auto-width" name="type" v-model="type" @change="changeType">
<option value="">[认证类型]</option>
<option value="">[鉴权类型]</option>
<option v-for="authType in authTypes" :value="authType.code">{{authType.name}}</option>
</select>
<p class="comment" v-html="authDescription"></p>
</td>
</tr>
<!-- TypeA -->
<tbody v-show="type == 'typeA'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeASecret" v-model="typeASecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeASecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>签名参数 *</td>
<td>
<input type="text" maxlength="30" name="typeASignParamName" value="sign" v-model="typeASignParamName" @input="changeTypeASignParamName"/>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeALife" value="30" style="width: 7em"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- TypeB -->
<tbody v-show="type == 'typeB'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeBSecret" v-model="typeBSecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeBSecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeBLife" value="30" style="width: 7em"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- TypeC -->
<tbody v-show="type == 'typeC'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeCSecret" v-model="typeCSecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeCSecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeCLife" value="30" style="width: 7em"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- TypeD -->
<tbody v-show="type == 'typeD'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeDSecret" v-model="typeDSecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeDSecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>签名参数 *</td>
<td>
<input type="text" maxlength="30" name="typeDSignParamName" value="sign" v-model="typeDSignParamName" @input="changeTypeDSignParamName"/>
</td>
</tr>
<tr>
<td>时间戳参数 *</td>
<td>
<input type="text" maxlength="30" name="typeDTimestampParamName" value="t" v-model="typeDTimestampParamName" @input="changeTypeDTimestampParamName"/>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeDLife" value="30" style="width: 7em"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- BasicAuth -->
<tbody v-show="type == 'basicAuth'">
<tr>
@@ -32,7 +134,7 @@
</tr>
<tr>
<td colspan="2">
<a href="" @click.prevent="showMoreBasicAuthOptions()">更多选项<i class="ui icon angle" :class="{up: moreBasicAuthOptionsVisible, down: !moreBasicAuthOptionsVisible}"></i></a>
<a href="" @click.prevent="showMoreBasicAuthOptions()">更多基本认证选项<i class="ui icon angle" :class="{up: moreBasicAuthOptionsVisible, down: !moreBasicAuthOptionsVisible}"></i></a>
</td>
</tr>
<tr v-show="moreBasicAuthOptionsVisible">
@@ -76,6 +178,25 @@
</td>
</tr>
</tbody>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>限定文件扩展名</td>
<td>
<values-box name="exts"></values-box>
<p class="comment">如果不为空,则表示只有这些扩展名的文件才需要鉴权;扩展名需要包含点符号(.),比如<code-label>.png</code-label></p>
</td>
</tr>
<tr>
<td>限定域名</td>
<td>
<domains-box></domains-box>
<p class="comment">如果不为空,则表示只有这些域名的文件才需要鉴权。</p>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>

View File

@@ -3,6 +3,7 @@ Tea.context(function () {
this.type = ""
this.authDescription = ""
this.rawDescription = ""
this.changeType = function () {
let that = this
@@ -11,11 +12,78 @@ Tea.context(function () {
})
if (authType != null) {
this.authDescription = authType.description
this.rawDescription = authType.description
} else {
this.authDescription = ""
this.rawDescription = ""
}
}
/**
* TypeA
*/
this.typeASecret = ""
this.typeASignParamName = "sign"
this.generateTypeASecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeASecret = resp.data.random
})
}
this.changeTypeASignParamName = function () {
this.authDescription = this.rawDescription.replace("sign=", this.typeASignParamName + "=")
}
/**
* TypeB
*/
this.typeBSecret = ""
this.generateTypeBSecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeBSecret = resp.data.random
})
}
/**
* TypeC
*/
this.typeCSecret = ""
this.generateTypeCSecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeCSecret = resp.data.random
})
}
/**
* TypeD
*/
this.typeDSecret = ""
this.typeDSignParamName = "sign"
this.typeDTimestampParamName = "t"
this.generateTypeDSecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeDSecret = resp.data.random
})
}
this.changeTypeDSignParamName = function () {
this.authDescription = this.rawDescription.replace("sign=", this.typeDSignParamName + "=")
this.authDescription = this.authDescription.replace("t=", this.typeDTimestampParamName + "=")
}
this.changeTypeDTimestampParamName = function () {
this.authDescription = this.rawDescription.replace("sign=", this.typeDSignParamName + "=")
this.authDescription = this.authDescription.replace("t=", this.typeDTimestampParamName + "=")
}
/**
* 基本认证
*/

View File

@@ -3,10 +3,10 @@
{$template "/left_menu_with_menu"}
<div class="right-box with-menu">
<form class="ui form" data-tea-action="$" data-tea-success="success">
<form class="ui form" data-tea-action="$" data-tea-success="success" ref="authForm">
<csrf-token></csrf-token>
<input type="hidden" name="webId" :value="webId">
<http-auth-config-box :v-auth-config="authConfig"></http-auth-config-box>
<submit-btn></submit-btn>
<http-auth-config-box :v-auth-config="authConfig" @change="changeMethods"></http-auth-config-box>
<submit-btn @ref=""></submit-btn>
</form>
</div>

View File

@@ -1,3 +1,10 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
this.changeMethods = function (config) {
Tea.action("$")
.form(this.$refs.authForm)
.post()
teaweb.successRefresh("保存成功")
}
})

View File

@@ -1,6 +1,6 @@
{$layout "layout_popup"}
<h3>修改认证方式</h3>
<h3>修改鉴权方式</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="policyId" :value="policy.id"/>
@@ -13,13 +13,115 @@
</td>
</tr>
<tr>
<td>认证类型 *</td>
<td>鉴权类型 *</td>
<td>
{{policy.typeName}}
<p class="comment" v-html="authDescription"></p>
</td>
</tr>
<!-- TypeA -->
<tbody v-show="type == 'typeA'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeASecret" v-model="typeASecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeASecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>签名参数 *</td>
<td>
<input type="text" maxlength="30" name="typeASignParamName" value="sign" v-model="typeASignParamName" @input="changeTypeASignParamName"/>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeALife" value="30" style="width: 7em" v-model="policy.params.life"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- TypeB -->
<tbody v-show="type == 'typeB'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeBSecret" v-model="typeBSecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeBSecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeBLife" value="30" style="width: 7em" v-model="policy.params.life"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- TypeC -->
<tbody v-show="type == 'typeC'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeCSecret" v-model="typeCSecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeCSecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeCLife" value="30" style="width: 7em" v-model="policy.params.life"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- TypeD -->
<tbody v-show="type == 'typeD'">
<tr>
<td>鉴权密钥 *</td>
<td>
<input type="text" maxlength="40" name="typeDSecret" v-model="typeDSecret" autocomplete="off"/>
<p class="comment">只能包含字母、数字长度不超过40。<a href="" @click.prevent="generateTypeDSecret()">[随机生成]</a></p>
</td>
</tr>
<tr>
<td>签名参数 *</td>
<td>
<input type="text" maxlength="30" name="typeDSignParamName" value="sign" v-model="typeDSignParamName" @input="changeTypeDSignParamName"/>
</td>
</tr>
<tr>
<td>时间戳参数 *</td>
<td>
<input type="text" maxlength="30" name="typeDTimestampParamName" value="t" v-model="typeDTimestampParamName" @input="changeTypeDTimestampParamName"/>
</td>
</tr>
<tr>
<td>有效时间</td>
<td>
<div class="ui input right labeled">
<input type="text" maxlength="8" name="typeDLife" value="30" style="width: 7em" v-model="policy.params.life"/>
<span class="ui label"></span>
</div>
<p class="comment">链接有效时间。</p>
</td>
</tr>
</tbody>
<!-- BasicAuth -->
<tbody v-show="type == 'basicAuth'">
<tr>
@@ -30,7 +132,7 @@
</tr>
<tr>
<td colspan="2">
<a href="" @click.prevent="showMoreBasicAuthOptions()">更多选项<i class="ui icon angle" :class="{up: moreBasicAuthOptionsVisible, down: !moreBasicAuthOptionsVisible}"></i></a>
<a href="" @click.prevent="showMoreBasicAuthOptions()">更多基本认证选项<i class="ui icon angle" :class="{up: moreBasicAuthOptionsVisible, down: !moreBasicAuthOptionsVisible}"></i></a>
</td>
</tr>
<tr v-show="moreBasicAuthOptionsVisible">
@@ -76,9 +178,28 @@
</tr>
</tbody>
<tr>
<td>是否启用</td>
<td><checkbox name="isOn" value="1" v-model="policy.isOn"></checkbox></td>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>限定文件扩展名</td>
<td>
<values-box name="exts" :v-values="policy.params.exts"></values-box>
<p class="comment">如果不为空,则表示只有这些扩展名的文件才需要鉴权;扩展名需要包含点符号(.),比如<code-label>.png</code-label></p>
</td>
</tr>
<tr>
<td>限定域名</td>
<td>
<domains-box :v-domains="policy.params.domains"></domains-box>
<p class="comment">如果不为空,则表示只有这些域名的文件才需要鉴权。</p>
</td>
</tr>
<tr>
<td>是否启用</td>
<td><checkbox name="isOn" value="1" v-model="policy.isOn"></checkbox></td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>

View File

@@ -3,6 +3,7 @@ Tea.context(function () {
this.type = this.policy.type
this.authDescription = ""
this.rawDescription = ""
this.$delay(function () {
this.changeType()
@@ -16,13 +17,106 @@ Tea.context(function () {
if (authType != null) {
this.policy.typeName = authType.name
this.authDescription = authType.description
this.rawDescription = authType.description
} else {
this.authDescription = ""
this.rawDescription = ""
}
}
/**
* 基本认证
* TypeA
*/
this.typeASecret = ""
this.typeASignParamName = "sign"
if (this.policy.type == "typeA") {
this.typeASecret = this.policy.params.secret
this.typeASignParamName = this.policy.params.signParamName
this.$delay(function () {
this.changeTypeASignParamName()
})
}
this.generateTypeASecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeASecret = resp.data.random
})
}
this.changeTypeASignParamName = function () {
this.authDescription = this.rawDescription.replace("sign=", this.typeASignParamName + "=")
}
/**
* TypeB
*/
this.typeBSecret = ""
if (this.policy.type == "typeB") {
this.typeBSecret = this.policy.params.secret
}
this.generateTypeBSecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeBSecret = resp.data.random
})
}
/**
* TypeC
*/
this.typeCSecret = ""
if (this.policy.type == "typeC") {
this.typeCSecret = this.policy.params.secret
}
this.generateTypeCSecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeCSecret = resp.data.random
})
}
/**
* TypeD
*/
this.typeDSecret = ""
this.typeDSignParamName = "sign"
this.typeDTimestampParamName = "t"
if (this.policy.type == "typeD") {
this.typeDSecret = this.policy.params.secret
this.typeDSignParamName = this.policy.params.signParamName
this.typeDTimestampParamName = this.policy.params.timestampParamName
this.$delay(function () {
this.changeTypeDSignParamName()
this.changeTypeDTimestampParamName()
})
}
this.generateTypeDSecret = function () {
this.$post(".random")
.success(function (resp) {
this.typeDSecret = resp.data.random
})
}
this.changeTypeDSignParamName = function () {
this.authDescription = this.rawDescription.replace("sign=", this.typeDSignParamName + "=")
this.authDescription = this.authDescription.replace("t=", this.typeDTimestampParamName + "=")
}
this.changeTypeDTimestampParamName = function () {
this.authDescription = this.rawDescription.replace("sign=", this.typeDSignParamName + "=")
this.authDescription = this.authDescription.replace("t=", this.typeDTimestampParamName + "=")
}
/**
* 基本鉴权
*/
this.moreBasicAuthOptionsVisible = false

View File

@@ -6,10 +6,10 @@
{$template "../left_menu"}
<div class="right-box tiny">
<form class="ui form" data-tea-action="$" data-tea-success="success">
<form class="ui form" data-tea-action="$" data-tea-success="success" ref="authForm">
<csrf-token></csrf-token>
<input type="hidden" name="webId" :value="webId">
<http-auth-config-box :v-auth-config="authConfig" :v-is-location="true"></http-auth-config-box>
<http-auth-config-box :v-auth-config="authConfig" :v-is-location="true" @change="changeMethods"></http-auth-config-box>
<submit-btn></submit-btn>
</form>
</div>

View File

@@ -1,3 +1,10 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
this.changeMethods = function (config) {
Tea.action("$")
.form(this.$refs.authForm)
.post()
teaweb.successRefresh("保存成功")
}
})