简体   繁体   English

在Oauth2中哪里存储client_id和client_secret?

[英]Where to store client_id and client_secret in Oauth2?

I would like to bring a login with Github and Facebook to my single page web app, the server is under my control. 我想将GithubFacebook登录到我的单页Web应用程序中,服务器由我控制。

In this tutorial https://spring.io/guides/tutorials/spring-boot-oauth2/ they store the client_id and client_secret in a file. 在本教程https://spring.io/guides/tutorials/spring-boot-oauth2/中,它们将client_idclient_secret存储在文件中。

Wouldn't it be more convenient if I stored these 2 in my backend database ? 如果将这2个存储在后端数据库中会更方便吗? Let's say someone who's not a programmer would like to register the web app to a new service , he could do that easily opening the database , he doesn't have to crawl into the backend project code. 假设不是程序员的人希望将Web应用程序注册到新服务,他可以轻松地打开database ,而不必爬入后端项目代码。

If not then where should these 2 be stored ? 如果不是,那么这2个应该存储在哪里?

If you talk about the convenience, storing these in a property file is a good option. 如果您谈论便利,将它们存储在属性文件中是个不错的选择。 By doing so, the properties can be easily loaded into the application during the startup. 这样,可以在启动过程中轻松地将属性加载到应用程序中。 If you change the values, all you need to do is just restart the app and the new values will be reflected. 如果更改值,则只需重启应用程序,新值就会反映出来。

I am not sure I understand your non-programmer related comment 100%. 我不确定我是否100%理解您与程序员无关的评论。 But IMO, for a non-programmer, modifying a file is much easier than modifying the DB. 但是,对于非程序员而言,IMO修改文件比修改DB容易得多。

Just to be more clear, the client id and the client secret represents the credentials of your application registered with the social media (like facebook). 为了更清楚一点,客户端ID和客户端机密代表在社交媒体(如Facebook)上注册的应用程序的凭据。

Ans yes, you can store these in DB as well. 是的,您也可以将它们存储在数据库中。 But then, you need to write code to fetch these values from the DB and load into your application. 但是随后,您需要编写代码以从数据库中获取这些值并加载到您的应用程序中。

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

相关问题 Spring Security OAuth2服务器端,如何在所有请求上要求client_id和client_secret - Spring Security OAuth2 server side, how to require client_id and client_secret on all request OAuth2客户端ID和客户端密钥的安全性 - Security of OAuth2 Client Id and Client Secret 将 oauth2 client-id 和 client-secret 从 spring 引导 bean 传递到 yaml 文件 - pass oauth2 client-id and client-secret from spring boot bean to yaml file OAuth2Authentication.getPrincipal()返回client_id而不是用户名 - OAuth2Authentication.getPrincipal() returns client_id instead of username 如何使用Spring在OAuth2身份验证中生成客户端密钥 - How to generate Client Secret in OAuth2 Authentication using Spring 客户端密钥+在spring oauth2中刷新访问令牌 - Client secret + refreshing the access token in spring oauth2 春季安全-参数中没有client_secret的访问令牌 - Spring Security - Access Token without client_secret in parameters 如何通过 Spring 引导动态更改 Spring Security 中的 client_secret - How to dynamically change client_secret in Spring Security with Spring boot Spring Security oauth 2客户端凭证:RemoteTokenServices空客户端ID或检测到的客户端密钥 - Spring Security oauth 2 client credentials: RemoteTokenServices Null Client ID or Client Secret detected Spring OAuth2 通过 Client-Id 获取 UserInfoUri - Spring OAuth2 pass Client-Id to get UserInfoUri
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM