How to generate Client Secret in OAuth2 Authentication using Spring

不羁的心 提交于 2019-12-23 05:24:02

问题


I am working on creating api for OAuth2 using Spring for my application but there is nothing written in the specification (http://tools.ietf.org/html/rfc6749) nor in Spring OAuth2 Documentation about how to generate client secret.

Do anyone have any idea?


回答1:


Spring uses PasswordEncoder for decoding/encoding clients secrets. See the JdbcClientDetailsService (if you're planning to store client details in DB).

So when configuring beans for Spring OAuth2 you typically provide an instance of PasswordEncoder for the ClientDetailsService.

Typical case is to use the BCryptPasswordEncoder. So before putting encoded client secret into database column you can write a sample program to generate it:

String password = "testPassword";
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode(password);


来源:https://stackoverflow.com/questions/21058665/how-to-generate-client-secret-in-oauth2-authentication-using-spring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!