Javascript 以URL参数结尾的帖子中的表单正文?
我们的堆栈:Javascript 以URL参数结尾的帖子中的表单正文?,javascript,vue.js,security,matomo,Javascript,Vue.js,Security,Matomo,我们的堆栈: 使用vuetify组件库的Vue.js前端 使用flask+tornado定制python中间件RESTAPI matomo在外部运行,并使用VUE连接到前端 插件系统。() 我们最近在我们的网站上添加了matamo,我们很少注意到数千个用户中有4个用户的用户名/密码(通过POST请求提交到我们的中间件)最终登录到matamo 奇怪的是,登录的实际路径是somesite.com/login,所以奇怪的matamo在主页上看到了它 以下是我们用于用户登录的代码: auth.js
- 使用vuetify组件库的Vue.js前端
- 使用flask+tornado定制python中间件RESTAPI
- matomo在外部运行,并使用VUE连接到前端 插件系统。()
const authenicateUser = async (username, password) => {
const body = { username: username, password: password }
const headers = new Headers()
headers.append('Content-Type', 'application/json')
headers.append('Accept', 'application/json')
try {
const response = await fetch('https://somesite.com/users/login', {
method: 'POST',
...(body ? { body: JSON.stringify(body) } : {}),
cache: 'no-store',
credentials: 'include', // this is to allow cross origin requests to our middleware microservice
headers: headers
})
return response
} catch (error) {
return false
}
}
登录表单
<v-form @submit.prevent="submit" @keyup.native.enter="submit" id="check-login-form">
<v-text-field
class="input-field"
label="MS ID"
v-model="username"
name="username"
data-cy="userName"
prepend-icon="mdi-account"
type="text"
color="rgb(232, 119, 34)"
/>
<div class="password-field">
<v-text-field
class="input-field"
id="password"
data-cy="userPassword"
label="Password"
v-model="password"
name="password"
prepend-icon="mdi-lock"
:type="showPassword ? 'text' : 'password'"
@click:append="showPassword = !showPassword"
color="rgb(232, 119, 34)"
></v-text-field>
<div v-if="showPassword" class="icon-container" v-on:click="toggleShowPassword">
<img src="~assets/Icons/View.svg" class="eye-icon" />
</div>
<div v-else class="icon-container" v-on:click="toggleShowPassword">
<img src="~assets/Icons/ViewHide.svg" class="eye-icon" />
</div>
</div>
</v-form>
你知道为什么会发生这种情况吗 我们最终通过将
方法=“POST”
attr添加到
来解决这个问题。在一些罕见的情况下,表单会尝试以GET的形式提交,这导致表单参数以URL参数的形式出现在URL中
。。。
async submit() {
this.isLoading = true
const response = await authenticateUser(this.username, this.password)
this.statusCode = response.status
this.currentStatusCode = this.statusCode
if (this.statusCode === 200) {
this.currentStatusCode = this.statusCode
this.$router.push('/')
this.isLoading = false
this.$matomo.setUserId(this.username)
} else {
this.isLoading = false
this.currentStatusCode = null
this.showPassword = false
}
},
toggleShowPassword: function() {
this.showPassword = !this.showPassword
}
},