2019-04-25

```

@Configuration

@EnableAuthorizationServer

public class MyAuthorizationServerConfigurerAdapterextends AuthorizationServerConfigurerAdapter {

@Bean

public JwtAccessTokenConverter jwtAccessTokenConverter() {

JwtAccessTokenConverter accessTokenConverter =new JwtAccessTokenConverter();

/*設(shè)置簽名*/

? accessTokenConverter.setSigningKey("smallsnail");

return accessTokenConverter;

}

@Autowired

private AuthenticationManagerauthenticationManager;

@Autowired

private RedisConnectionFactoryredisConnection;

@Autowired

? ? private DataSourcedataSource;

@Bean

? ? public ClientDetailsService clientDetailsService() {

return new JdbcClientDetailsService(dataSource);

}

@Override

public void configure(AuthorizationServerSecurityConfigurer security)throws Exception {

super.configure(security);

}

@Override

public void configure(AuthorizationServerEndpointsConfigurer endpoints)throws Exception {

/*redis存儲token*/

/*endpoints.authenticationManager(authenticationManager).tokenStore(new MyRedisTokenStore(redisConnection));*/

? /*jwt方式*/

/*endpoints.accessTokenConverter(jwtAccessTokenConverter());

endpoints.authenticationManager(authenticationManager).tokenStore(new JwtTokenStore(jwtAccessTokenConverter()));*/

? /*jwt方式+redis存儲token*/

? endpoints.accessTokenConverter(jwtAccessTokenConverter());

endpoints.authenticationManager(authenticationManager).tokenStore(new MyRedisTokenStore(redisConnection));

}

@Override

public void configure(ClientDetailsServiceConfigurer clients)throws Exception {

clients.withClientDetails(clientDetailsService());

}

}

```

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 上滑固定副標(biāo)題時一定要設(shè)置scrollview的minheight>整個屏幕,不然滑動會出現(xiàn)錯層的情況 packa...
    菜神一把梭閱讀 312評論 0 1
  • Spring單例學(xué)習(xí)1.概述2.練習(xí)2.1.接口定義package com.tech.ability.spring...
    kikop閱讀 379評論 0 0
  • 今天要篩選一些數(shù)據(jù) 比如取當(dāng)天的數(shù)據(jù) 或者前天 大前天等等等 。。。記錄一下 菜雞下蛋 上代碼了 public S...
    長安_e9aa閱讀 140評論 0 0
  • 最近在開發(fā)一個小程序,其中涉及動效需求,我們原先的計劃是使用gif圖實現(xiàn)該動效,但是gif圖有如下三個缺點(diǎn): 高質(zhì)...
    廣州蘆葦科技web前端閱讀 316評論 0 0
  • 男同志最近買了泳鏡,浴缸太小,心癢難耐。 說是要去游泳。找了個大學(xué)里對外開放的游泳館。 據(jù)說新建的,水特別好。 我...
    S貓閱讀 546評論 5 4

友情鏈接更多精彩內(nèi)容