爲了跟蹤Yuci,我創建了一個Spring和Spring引導集成示例的存儲庫。有些需要的只是配置。 ORCID最近發佈了OpenID Connect和隱式OAuth功能,現在您還可以使用少量的JavaScript來進行客戶端身份驗證。
在ORCID結束的變化意味着春天啓動需要什麼比this更多:
@SpringBootApplication
@EnableOAuth2Sso
@Controller
public class ReallySimpleOrcidOauthApplication {
@RequestMapping("/")
@ResponseBody
public final String home() {
return "Welcome, " + SecurityContextHolder.getContext().getAuthentication().getName();
}
public static void main(String[] args) {
SpringApplication application = new SpringApplication(ReallySimpleOrcidOauthApplication.class);
Properties properties = new Properties();
properties.put("security.oauth2.client.clientId", "XXX");
properties.put("security.oauth2.client.clientSecret", "XXX");
properties.put("security.oauth2.client.accessTokenUri", "https://sandbox.orcid.org/oauth/token");
properties.put("security.oauth2.client.userAuthorizationUri", "https://sandbox.orcid.org/oauth/authorize");
properties.put("security.oauth2.client.tokenName", "access_token");
properties.put("security.oauth2.client.scope", "openid");
properties.put("security.oauth2.resource.userInfoUri", "https://sandbox.orcid.org/oauth/userinfo");
application.setDefaultProperties(properties);
application.run(args);
}
}
有使用JWT以及客戶端僅隱流的例子。這個和更多ORCID OAuth和OpenID連接示例可以是found on github
來源
2017-11-09 12:32:25
tom