简体   繁体   English

如果我的网站没有登录页面,如何设置 api 授权

[英]How to setup api authorization if I don't have a login page in my website

I want to set up authorization in my react app.我想在我的反应应用程序中设置授权。 This is for security reasons, so my API will only be accessed by the people who use our website.这是出于安全原因,所以我的 API 只能由使用我们网站的人访问。 But my web app doesn't have a user login and doesn't require any.但是我的 web 应用程序没有用户登录,也不需要任何登录。 my backend uses rest api.我的后端使用 rest api。

  • How would I proceed with authorization with a token?我将如何使用令牌进行授权?
  • How can I set up an initial token even before the page loads?如何在页面加载之前设置初始令牌?

Something like a token will not work since it sounds like your app is public and therefore anyone could grab the token (being a browser based thing) and use that on their own.令牌之类的东西不起作用,因为听起来您的应用程序是公开的,因此任何人都可以获取令牌(作为基于浏览器的东西)并自己使用它。 Instead I'd explore CORS to control the origin - for example only allowing your website to be authorized to perform the api call.. Here's an article on using CORS with the AWS API Gateway. Instead I'd explore CORS to control the origin - for example only allowing your website to be authorized to perform the api call.. Here's an article on using CORS with the AWS API Gateway.

https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我在 Fetch API 中设置了授权承载,但我的请求标头中没有授权 - I have Authorization Bearer set in Fetch API but there is no Authorization in my Request Headers React Native:如何设置 React Navigation 类型,这样我就不必在我使用的每个组件上创建 NavigationProps? - React Native: How to setup React Navigation types so I don't have to create NavigationProps on each component I use? 为什么我不能在我的 API 控制器中使用角色授权 - Why can't I use role authorization in my API controller 如何为我的API和我的websocket设置路由 - How do i setup routing for my API and my websocket 如何将记住登录详细信息按钮添加到我的网站? - How do I add a remember login details button to my website? 我在 React 中的登录页面没有提供我想要的 output - My Login page in React isn't giving the output that I want 如何使用 prevState 这样我就不必使用 setTimeout - How to use prevState so I don't have to use a setTimeout 为什么我的反应网站没有打印我的登录页面? - why is my react website not printing my login page? 每次打开我的页面都会闪烁。 我在组件内没有很多代码。 我不知道如何解决它。 我在组件中获取数据 - My pages flicker every time I open them. I don't have a lot of code inside the component. I don't know how to fix it. I fetch the data in the compon 当我使用 history.push() 我的组件不呈现时,我需要刷新页面 - When I use history.push() my component don't render, I need to refresh the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM