Skip to content

[FEATURE]如何在前端程序调用 1Panel 的 API 接口 #4038

Closed

Description

@ikxin

1Panel 版本

v1.10.0-lts

请描述您的需求或者改进建议

我想在其他的前端程序调用 1Panel 的接口,但是会遇到 CORS 跨域问题,请问可以在后端的接口加上 Access-Control-Allow-Origin: * 这个 header 吗,会不会产生安全问题?

如果会的话,那是否可以考虑开发一个功能,可以自定义配置白名单,允许指定的地址请求API接口。

另外,我看到现在的前后端分离用的是 cookie 来鉴权,后期是否有计划使用 jwt,这个好像用在前端更方便调用。

以上是我的一些想法和建议,希望开发者有时间可以看一下,愿 1Panel 越来越好,引领国内开源环境的发展!

请描述你建议的实现方案

No response

附加信息

No response

Activity

  1. zhangyz189 commented on Mar 1, 2024

    @zhangyz189

    jwt目前是支持的
    curl 'http://127.0.0.1:7001/api/v1/auth/login' --data-binary '{"name":"admin_test","password":"admin_test1234","ignoreCaptcha":true,"captcha":"","captchaID":"nY8Cqeut3TjZMfJMAz0k","authMethod":"jwt","language":"zh"}' -H 'EntranceCode: emhhbmd5eg=='
    curl 'http://127.0.0.1:7001/api/v1/dashboard/current/all/all' -H 'PanelAuthorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MCwiTmFtZSI6ImFkbWluX3Rlc3QiLCJCdWZmZXJUaW1lIjozNjAwLCJpc3MiOiIxUGFuZWwiLCJleHAiOjE3MDkyODg4MDl9.pdknJdjLY4Fp8wCE9Gvaiic2rLoSdvUSJB9ossyya_I'

  2. ikxin commented on Mar 2, 2024

    @ikxin
    Author

    jwt目前是支持的 curl 'http://127.0.0.1:7001/api/v1/auth/login' --data-binary '{"name":"admin_test","password":"admin_test1234","ignoreCaptcha":true,"captcha":"","captchaID":"nY8Cqeut3TjZMfJMAz0k","authMethod":"jwt","language":"zh"}' -H 'EntranceCode: emhhbmd5eg==' curl 'http://127.0.0.1:7001/api/v1/dashboard/current/all/all' -H 'PanelAuthorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MCwiTmFtZSI6ImFkbWluX3Rlc3QiLCJCdWZmZXJUaW1lIjozNjAwLCJpc3MiOiIxUGFuZWwiLCJleHAiOjE3MDkyODg4MDl9.pdknJdjLY4Fp8wCE9Gvaiic2rLoSdvUSJB9ossyya_I'

    感谢回复,但 jwt 好像仍有 cors 跨域问题

  3. mobeicanyue commented on Mar 6, 2024

    @mobeicanyue
    Contributor

    @wanghe-fit2cloud 建议这类非BUG 和新需求问题可以开启 Github Discussion 进行讨论。Issue 专注于BUG 和新需求
    1000057588

  4. wanghe-fit2cloud commented on Mar 6, 2024

    @wanghe-fit2cloud
    Member

    建议这类非BUG 和新需求问题可以开启 Github Discussion 进行讨论。Issue 专注于BUG 和新需求

    感谢建议。

  5. locked and limited conversation to collaborators on Mar 8, 2024
  6. converted this issue into a discussion #4120 on Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions