Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week 4. client_id處理問題 #11

Open
AngeloETH opened this issue Sep 7, 2018 · 1 comment
Open

Week 4. client_id處理問題 #11

AngeloETH opened this issue Sep 7, 2018 · 1 comment

Comments

@AngeloETH
Copy link

如題,想請問一下實務上如何處理金鑰等敏感資訊呢? 如果直接放在同一個.js檔裡,是不是有暴露的風險,其他人也可以用你的client_id去做壞壞的事情。若要避免這樣的問題,請問一下實務上通常會怎麼處理呢?甚至是放到雲端主機上要如何避免client透過browser存取你的敏感資訊。

@aszx87410
Copy link
Member

首先,從 client 端沒法避免,因為 .js 檔就是一個跑在你電腦上的東西,所以你怎麼防也不可能防別人偷這個 client_id,就算你加密了,你的 request 一樣可以在 devtool 被看到,所以防不了。

所以一般來說解法有兩種:

  1. 有些服務會提供設定,可以設置允許存取的 domain,你可以自己添加白名單過濾
  2. 自己寫後端去接這個 API,意思就是你前端 ajax 打自己 API,後端再去打你接的 API 拿資料,這樣 client_id 就是在後端了

不過通常會叫 client_id 的都不太重要,別人也可以自己去免費申請一個,沒有必要用你的,除非想故意害你後台多一堆奇怪的資料就是了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants