我目前正在使用 VSCode 处理 .net 核心 api 项目,并且我想将 ASP.NET 核心身份验证和授权与 cookie 集成。
我试图添加services.AddAuthentication();和services.AddAuthorization();在Startup.cs。我还在[Authorize]我的UsersController.cs.
[Authorize]
[Route("api/Users")]
[ApiController]
public class UsersController : ControllerBase
Run Code Online (Sandbox Code Playgroud)
问题是当我启动我的应用程序时,即使我没有创建用户或角色,我仍然可以访问我的 API。( https://localhost:5001/api/Users)
我尝试设置launchSettings.json如下:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:49086",
"sslPort": 44343
}
Run Code Online (Sandbox Code Playgroud)
但我仍然可以访问我的 API。如果没有用户或角色,如何拒绝访问?
我肯定错过了一些东西,但我不知道是什么。
预先感谢您的帮助!
1 周前,我一直在为一个项目使用 VueJS。
我创建了两个组件: * Account.vue (Parent)
<!--It's just a little part of the code-->
<e-textarea
title="Informations complémentaires"
@input="otherInformation" <!--otherInformation is a string variable which contains the text value-->
:value="otherInformation"></e-textarea>
Run Code Online (Sandbox Code Playgroud)
<template>
<div class="form-group">
<label for="e-textarea">{{ title }}</label>
<textarea
id="e-textarea"
class="form-control"
row="3"
:value="value"
v-on="listeners"
>
</textarea>
</div>
</template>
<script>
import { FormGroupInput } from "@/components/NowUiKit";
export default {
name: "e-textarea",
components: {
[FormGroupInput.name]: FormGroupInput
},
props: {
title: String,
value: String
},
computed: {
listeners() {
return {
...this.$listeners, …Run Code Online (Sandbox Code Playgroud)