锘??xml version="1.0" encoding="utf-8" standalone="yes"?>一区二区成人国产精品,国产亚洲午夜高清国产拍精品,国产精品一区二区免费看http://www.aygfsteel.com/paulwong/category/54901.htmlzh-cnFri, 07 Jan 2022 13:33:46 GMTFri, 07 Jan 2022 13:33:46 GMT60OAUTH2 - 4嫻佺▼濡備綍閫夋嫨錛?/title><link>http://www.aygfsteel.com/paulwong/archive/2022/01/06/438648.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Thu, 06 Jan 2022 05:37:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2022/01/06/438648.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/438648.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2022/01/06/438648.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/438648.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/438648.html</trackback:ping><description><![CDATA[<a target="_blank"> <img src="https://developer.okta.com/img/oauth_grant_flowchart.png" width="600" height="254" alt="" /> </a><br /><br /> <br /> <br /> <a target="_blank">https://developer.okta.com/docs/concepts/oauth-openid/#what-kind-of-client-are-you-building</a><img src ="http://www.aygfsteel.com/paulwong/aggbug/438648.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2022-01-06 13:37 <a href="http://www.aygfsteel.com/paulwong/archive/2022/01/06/438648.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>OIDC - KEYCLOAK - 鑷畾涔塁LIENT SCOPEhttp://www.aygfsteel.com/paulwong/archive/2021/12/22/436242.htmlpaulwongpaulwongWed, 22 Dec 2021 03:15:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/12/22/436242.htmlhttp://www.aygfsteel.com/paulwong/comments/436242.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/12/22/436242.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/436242.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/436242.html
"resource_access": {
    "app-springboot-confidential": {
      "roles": [
        "user"
      ]
    },
    "test-employee-service": {
      "roles": [
        "READ_EMPLOYEE"
      ]
    },
    "service-springboot": {
      "roles": [
        "READ_PRODUCTS"
      ]
    },
    "account": {
      "roles": [
        "manage-account",
        "manage-account-links"
      ]
    },
    "test-department-service": {
      "roles": [
        "READ_DEPARTMENT"
      ]
    }
  }

  • 闇瑕佸皢鏉冮檺鐨勪俊鎭緭鍑哄埌涓涓狵EY涓紝榪欐椂鍙互鏂板鑷畾涔塁LIENT SCOPE銆侻apper涓柊澧濳EYCLOAK宸插唴緗殑銆恟ealm roles/client roles銆戯紝瀹氫箟杈撳嚭鍒癑TW鐨勫瓧孌靛悕錛歮y-roles銆?/li>
  • 鎺堟潈鍝簺CLIENT鍙互璇誨彇姝LIENT SCOPE.
  • 鍦ㄧ櫥褰曞弬鏁皊cope涓紝鍔犲叆姝ゅ鹼細my-roles錛岃繖鏍峰湪杈撳嚭鐨凧WT灝變細浠ュ鉤闈㈢殑鏂瑰紡杈撳嚭鎵鏈塺oles
"my-roles": [
    "user",
    "READ_EMPLOYEE",
    "READ_PRODUCTS",
    "manage-account",
    "manage-account-links",
    "READ_DEPARTMENT",
    "offline_access",
    "user"
  ]

  • SPRING SECURITY涓彇鍑烘潈闄愪俊鎭細

@Bean
    public ReactiveJwtAuthenticationConverter jwtAuthenticationConverter(ObjectMapper objectMapper) {
        
        JwtGrantedAuthoritiesConverter jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
        jwtGrantedAuthoritiesConverter.setAuthorityPrefix("ROLE_");
        jwtGrantedAuthoritiesConverter.setAuthoritiesClaimName("my-roles");
        
//        KeycloakRealmRoleConverter keycloakRealmRoleConverter = new KeycloakRealmRoleConverter(objectMapper);
        
        ReactiveJwtGrantedAuthoritiesConverterAdapter reactiveJwtGrantedAuthoritiesConverterAdapter = 
                new ReactiveJwtGrantedAuthoritiesConverterAdapter(
//                        new KeycloakRealmRoleConverter(objectMapper);
                        jwtGrantedAuthoritiesConverter
                    );
        
        ReactiveJwtAuthenticationConverter jwtConverter = new ReactiveJwtAuthenticationConverter();
        jwtConverter.setJwtGrantedAuthoritiesConverter(reactiveJwtGrantedAuthoritiesConverterAdapter);
        
        return jwtConverter;
    }

  • 鍒ゆ柇鏄惁鏈夋潈闄?/li>

ServerHttpSecurity
            .authorizeExchange(
                a -> a.pathMatchers("/", "/error").permitAll()
                      .matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
                      .pathMatchers(HttpMethod.GET, "/protected/**").hasRole("READ_DEPARTMENT")
                      .anyExchange()
                      .authenticated()
             )


paulwong 2021-12-22 11:15 鍙戣〃璇勮
]]>
OAUTH2 - 4嫻佺▼http://www.aygfsteel.com/paulwong/archive/2021/12/16/436095.htmlpaulwongpaulwongThu, 16 Dec 2021 08:14:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/12/16/436095.htmlhttp://www.aygfsteel.com/paulwong/comments/436095.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/12/16/436095.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/436095.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/436095.html


Authorization Code Grant




Implicit Grant Flow




Client Credential





Password Grant flow





https://itnext.io/an-oauth-2-0-introduction-for-beginners-6e386b19f7a9

paulwong 2021-12-16 16:14 鍙戣〃璇勮
]]>
OAUTH2 - SPRING SECURITY + KEYCLOAKhttp://www.aygfsteel.com/paulwong/archive/2021/11/03/436029.htmlpaulwongpaulwongWed, 03 Nov 2021 08:58:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/11/03/436029.htmlhttp://www.aygfsteel.com/paulwong/comments/436029.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/11/03/436029.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/436029.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/436029.html闃呰鍏ㄦ枃

paulwong 2021-11-03 16:58 鍙戣〃璇勮
]]>
SPRING BOOT OAUTH2 + KEYCLOAK - service to service callhttp://www.aygfsteel.com/paulwong/archive/2021/10/26/436021.htmlpaulwongpaulwongTue, 26 Oct 2021 09:06:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/10/26/436021.htmlhttp://www.aygfsteel.com/paulwong/comments/436021.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/10/26/436021.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/436021.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/436021.htmlemployee-service鐨刟pplication.yaml鏂囦歡錛屽叾涓殑public-key瑕佷粠KEYCLOAK涓彇
server:
   port: 8090
# Can be set to false to disable security during local development
rest:
   security:
      enabled: true
      #issuer-uri: http://localhost:8080/auth/realms/dev
      api-matcher: /api/**
      cors:
         allowed-origins: '*'
         allowed-headers: '*'
         allowed-methods: GET,POST,PUT,PATCH,DELETE,OPTIONS
         max-age: 3600

security:
   oauth2:
      resource:
         filter-order: 3
         id: test-employee-service
         token-info-uri: ${rest.security.issuer-uri}/protocol/openid-connect/token/introspect
         user-info-uri: ${rest.security.issuer-uri}/protocol/openid-connect/userinfo
         jwt:
            key-value: | 
               -----BEGIN PUBLIC KEY-----
               MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB
               -----END PUBLIC KEY-----

# To access another secured micro-service
      client:
         client-id: test-employee-service
         #client-secret: 25c33006-e1b9-4fc2-a6b9-c43dbc41ecd0
         user-authorization-uri: ${rest.security.issuer-uri}/protocol/openid-connect/auth
         access-token-uri: ${rest.security.issuer-uri}/protocol/openid-connect/token
         scope: openid
         grant-type: client_credentials
         is-client-only: true

#Logging Configuration
logging:
   level:
      org.springframework.boot.autoconfigure.logging: INFO
      org.springframework.security: DEBUG
      org.arun: DEBUG
      root: INFO

application-dev.yaml
rest:
   security:
      issuer-uri: http://10.80.27.69:8180/auth/realms/quickstart

department-service:
   url: http://10.80.27.69:8095/api/departments/1

security:
   oauth2:
      client:
         client-secret: db25cdbd-605b-429d-bd92-96705bdf1474

department-service鐨刟pplication.yaml
server:
   port: 8095
# Can be set to false to disable security during local development
rest:
   security:
      enabled: true
      #issuer-uri: http://localhost:8080/auth/realms/dev
      api-matcher: /api/**
      cors:
         allowed-origins: '*'
         allowed-headers: '*'
         allowed-methods: GET,POST,PUT,PATCH,DELETE,OPTIONS
         max-age: 3600

security:
   oauth2:
      resource:
         filter-order: 3
         id: test-department-service
         token-info-uri: ${rest.security.issuer-uri}/protocol/openid-connect/token/introspect
         user-info-uri: ${rest.security.issuer-uri}/protocol/openid-connect/userinfo
         jwt:
            key-value: | 
               -----BEGIN PUBLIC KEY-----
               MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB
               -----END PUBLIC KEY-----

#Logging Configuration
logging:
   level:
      org.springframework.boot.autoconfigure.logging: INFO
      org.springframework.security: DEBUG
      org.arun: DEBUG
      root: INFO

application-dev.yaml
rest:
   security:
      issuer-uri: http://10.80.27.69:8180/auth/realms/quickstart

employee-service鐨刾om.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.18.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>org.arun.springoauth</groupId>
    <artifactId>spring-oauth2-employee-service</artifactId>
    <version>1.0.0</version>
    <name>spring-oauth2-employee-service</name>
    <description>Employee Service</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-boot.version>2.1.18.RELEASE</spring-boot.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security.oauth.boot</groupId>
            <artifactId>spring-security-oauth2-autoconfigure</artifactId>
            <!-- <version>2.1.18.RELEASE</version> -->
            <version>${spring-boot.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <layout>ZIP</layout>
                    <excludes>
                        <exclude>
                            <groupId>*</groupId>
                            <artifactId>*</artifactId>
                        </exclude>
                    </excludes>
                    <includes>
                        <include>
                            <groupId>com.paul</groupId>
                        </include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

灝唈wt鏍煎紡鐨刟ccess_token杞垚Authentication鐨勭被JwtAccessTokenCustomizer
package org.arun.springoauth.employee.config;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.oauth2.resource.JwtAccessTokenConverterConfigurer;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.OAuth2Request;
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

@Configuration
public class JwtAccessTokenCustomizer extends DefaultAccessTokenConverter implements JwtAccessTokenConverterConfigurer {

    private static final Logger LOG = LoggerFactory.getLogger(JwtAccessTokenCustomizer.class);

    private static final String CLIENT_NAME_ELEMENT_IN_JWT = "resource_access";

    private static final String ROLE_ELEMENT_IN_JWT = "roles";

    private ObjectMapper mapper;

    @Autowired
    public JwtAccessTokenCustomizer(ObjectMapper mapper) {
        this.mapper = mapper;
        LOG.info("Initialized {}", JwtAccessTokenCustomizer.class.getSimpleName());
    }

    @Override
    public void configure(JwtAccessTokenConverter converter) {
        converter.setAccessTokenConverter(this);
        LOG.info("Configured {}", JwtAccessTokenConverter.class.getSimpleName());
    }

    /**
     * Spring oauth2 expects roles under authorities element in tokenMap, but
     * keycloak provides it under resource_access. Hence extractAuthentication
     * method is overriden to extract roles from resource_access.
     *
     * 
@return OAuth2Authentication with authorities for given application
     
*/
    @Override
    public OAuth2Authentication extractAuthentication(Map<String, ?> tokenMap) {
        LOG.debug("Begin extractAuthentication: tokenMap = {}", tokenMap);
        JsonNode token = mapper.convertValue(tokenMap, JsonNode.class);
        Set<String> audienceList = extractClients(token); // extracting client names
        List<GrantedAuthority> authorities = extractRoles(token); // extracting client roles

        OAuth2Authentication authentication = super.extractAuthentication(tokenMap);
        OAuth2Request oAuth2Request = authentication.getOAuth2Request();

        OAuth2Request request = new OAuth2Request(oAuth2Request.getRequestParameters(), oAuth2Request.getClientId(),
                authorities, true, oAuth2Request.getScope(), audienceList, nullnullnull);

        Authentication usernamePasswordAuthentication = new UsernamePasswordAuthenticationToken(
                authentication.getPrincipal(), "N/A", authorities);
        LOG.debug("End extractAuthentication");
        return new OAuth2Authentication(request, usernamePasswordAuthentication);
    }

    private List<GrantedAuthority> extractRoles(JsonNode jwt) {
        LOG.debug("Begin extractRoles: jwt = {}", jwt);
        Set<String> rolesWithPrefix = new HashSet<>();

        jwt.path(CLIENT_NAME_ELEMENT_IN_JWT).elements().forEachRemaining(e -> e.path(ROLE_ELEMENT_IN_JWT).elements()
                .forEachRemaining(r -> rolesWithPrefix.add("ROLE_" + r.asText())));

        final List<GrantedAuthority> authorityList = AuthorityUtils
                .createAuthorityList(rolesWithPrefix.toArray(new String[0]));
        LOG.debug("End extractRoles: roles = {}", authorityList);
        return authorityList;
    }

    private Set<String> extractClients(JsonNode jwt) {
        LOG.debug("Begin extractClients: jwt = {}", jwt);
        if (jwt.has(CLIENT_NAME_ELEMENT_IN_JWT)) {
            JsonNode resourceAccessJsonNode = jwt.path(CLIENT_NAME_ELEMENT_IN_JWT);
            final Set<String> clientNames = new HashSet<>();
            resourceAccessJsonNode.fieldNames().forEachRemaining(clientNames::add);

            LOG.debug("End extractClients: clients = {}", clientNames);
            return clientNames;

        } else {
            throw new IllegalArgumentException(
                    "Expected element " + CLIENT_NAME_ELEMENT_IN_JWT + " not found in token");
        }

    }

}



Reference
https://medium.com/@bcarunmail/securing-rest-api-using-keycloak-and-spring-oauth2-6ddf3a1efcc2





paulwong 2021-10-26 17:06 鍙戣〃璇勮
]]>
浣跨敤REST API涓嶬EYCLOAK榪涜OUATH2鍗忚鐨勭櫥褰曡璇?/title><link>http://www.aygfsteel.com/paulwong/archive/2021/10/12/436009.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 12 Oct 2021 06:40:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2021/10/12/436009.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/436009.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2021/10/12/436009.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/436009.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/436009.html</trackback:ping><description><![CDATA[KEYCLOAK鏄竴濂楃敤鎴楓乄EB API鐧誨綍綆$悊錛屾巿鏉冪鐞嗙殑WEB搴旂敤銆?br />濡傛灉瑕佽闂彈KEYCLOAK淇濇姢鐨凴EST API鏈嶅姟錛屽垯闇瑕佸す甯︿竴涓狝CCESS_TOKEN銆?br /><br />鍓嶇欏甸潰錛?br /><ul><li>鍓嶇欏甸潰涓鑸槸緇欑敤鎴蜂嬌鐢ㄧ殑錛屽垯闇瑕佺敤鎴瘋緭鍏ュ湪KEYCLOAK涓湁鏁堢殑鐢ㄦ埛鍚嶅拰瀵嗙爜錛屽茍鎻愪緵CALL BAK鐨刄RL錛屾彁浜ょ粰KEYCLOAK<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->http://10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/auth?client_id=app-springboot-confidential<span style="color: #FF0000; ">&redirect_uri</span>=http://10.80.27.69:8183/<span style="color: #FF0000; ">&response_type</span>=code<span style="color: #FF0000; ">&scope</span>=openid</div></li><li>濡傛灉KEYCLOAK楠岃瘉閫氳繃錛屽垯閫氱煡欏甸潰閲嶅鍚戝洖璋冪殑URL錛屽茍闄勪笂code=xxx錛屾code鍒欐槸AUTHORIZATION_CODE<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->http://10.80.27.69:8183/?session_state=2ad9ab98-6c39-43a8-872f-2112c27b74df<span style="color: #FF0000; ">&code</span>=3f48ce19-58f9-45d9-8c09-30d492bf4b24.2ad9ab98-6c39-43a8-872f-2112c27b74df.bd7526ef-b1bf-447f-baef-b7dfd6f0df93</div></li><li>鍥炶皟鐨刄RL瀵瑰簲鐨凷ERVELET錛屽彇寰桝UTHORIZATION_CODE錛屽茍鍔犱笂client_id鍜宑lient_secrect錛岃皟鐢↘EYLOAK鐨勫彇ACCESS_TOKEN鐨凥TTP API錛屽彇寰桝CCESS_TOKEN錛岃繑鍥炵粰欏甸潰<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->http://10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token<br />client_id=app-springboot-confidential<span style="color: #FF0000; ">&client_secret</span>=3acf7692-49cb-4c45-9943-6f3dba512dae<span style="color: #FF0000; ">&redirect_uri</span>=http://10.80.27.69:8183/<span style="color: #FF0000; ">&grant_type</span>=authorization_code<span style="color: #FF0000; ">&code</span>=cc7ac566-90f9-404e-b88e-fa28037b07d1.591311e1-5380-46a2-9363-834f17337922.bd7526ef-b1bf-447f-baef-b7dfd6f0df93</div></li><li>欏甸潰淇濆瓨姝CCESS_TOKEN錛屽氨鍙互璋冪敤鍚庡彴鐨勫悇縐岮PI鑾峰彇鏁版嵁<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->{<br />    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJleHAiOjE2MzQwMjA4ODksImlhdCI6MTYzNDAyMDU4OSwianRpIjoiNDAwOTQ4ZmQtMGU0MS00YWRjLTlhY2MtMzczZWM2NDVhNzM5IiwiaXNzIjoiaHR0cDovLzEwLjgwLjI3LjY5OjgxODAvYXV0aC9yZWFsbXMvcXVpY2tzdGFydCIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiJkZGVkMDA2YS0xY2QxLTRjODUtOTQ1MS0wMjFlZmY3OTFiMmUiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJhcHAtc3ByaW5nYm9vdC1jb25maWRlbnRpYWwiLCJzZXNzaW9uX3N0YXRlIjoiYzRlN2QzYTgtMDg2My00OTAwLTkxZmEtMGExYmFmYmRlNGU3IiwiYWNyIjoiMSIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYXBwLXNwcmluZ2Jvb3QtY29uZmlkZW50aWFsIjp7InJvbGVzIjpbInVtYV9wcm90ZWN0aW9uIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6InByb2ZpbGUgZW1haWwiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImNsaWVudElkIjoiYXBwLXNwcmluZ2Jvb3QtY29uZmlkZW50aWFsIiwiY2xpZW50SG9zdCI6IjEwLjEwLjIwLjU3IiwidXNlcl9uYW1lIjoic2VydmljZS1hY2NvdW50LWFwcC1zcHJpbmdib290LWNvbmZpZGVudGlhbCIsInByZWZlcnJlZF91c2VybmFtZSI6InNlcnZpY2UtYWNjb3VudC1hcHAtc3ByaW5nYm9vdC1jb25maWRlbnRpYWwiLCJjbGllbnRBZGRyZXNzIjoiMTAuMTAuMjAuNTcifQ.Ut6aZ6E1d4Esz0gRv2ubxdvrxmGvZLHHZepD5pnGxlqb_yZ4Q82TdGTG0iL4JJn2NH3QAU501dhzzuv6-OT9BUBKP-4ufyKv2DxSvt3GgdN30au5JsATHFyOWuuZGRBd3iWcynf9u3OJnSkHEnrIwRYatgndLzy8dy3AeqF12CI",<br />    "expires_in": 300,<br />    "refresh_expires_in": 600,<br />    "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI2MTlhMmJjOS0yMWIwLTRmNGMtODI4OC1kNTJmMjA3OWEzY2EifQ.eyJleHAiOjE2MzQwMjExODksImlhdCI6MTYzNDAyMDU4OSwianRpIjoiYTM0NTQ1MTYtMzc3NC00YmRlLTgzOTMtN2QyMTdkZjdkZmJkIiwiaXNzIjoiaHR0cDovLzEwLjgwLjI3LjY5OjgxODAvYXV0aC9yZWFsbXMvcXVpY2tzdGFydCIsImF1ZCI6Imh0dHA6Ly8xMC44MC4yNy42OTo4MTgwL2F1dGgvcmVhbG1zL3F1aWNrc3RhcnQiLCJzdWIiOiJkZGVkMDA2YS0xY2QxLTRjODUtOTQ1MS0wMjFlZmY3OTFiMmUiLCJ0eXAiOiJSZWZyZXNoIiwiYXpwIjoiYXBwLXNwcmluZ2Jvb3QtY29uZmlkZW50aWFsIiwic2Vzc2lvbl9zdGF0ZSI6ImM0ZTdkM2E4LTA4NjMtNDkwMC05MWZhLTBhMWJhZmJkZTRlNyIsInNjb3BlIjoicHJvZmlsZSBlbWFpbCJ9.QhjkJBGz5UvwBF7xHM7_V_yjfF0lrA_EWzAVdFf-BRI",<br />    "token_type": "bearer",<br />    "not-before-policy": 0,<br />    "session_state": "c4e7d3a8-0863-4900-91fa-0a1bafbde4e7",<br />    "scope": "profile email"<br />}</div></li><li>榪欏氨鏄痑uthorization_code嫻佺▼</li></ul><br />鍚庣鏈嶅姟錛?br /><ul><li>濡傛灉鏄湪涓涓狝PI涓璇鋒眰鍙﹀涓涓狝PI鐨勬暟鎹紝涓嶅瓨鍦ㄥ叿浣撶敤鎴風殑鎯呭喌</li><li>闇鎻愪緵濡備笅鍙傛暟錛歝lient_id銆乧lient_secrect鍜実rant_type錛屼笖grant_type=client_credentials錛岃皟鐢↘EYLOAK鐨勫彇ACCESS_TOKEN鐨凥TTP API錛屽彇寰桝CCESS_TOKEN<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->http:<span style="color: #008000; ">//</span><span style="color: #008000; ">10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token</span><span style="color: #008000; "><br /></span>client_id=app-springboot-confidential&client_secret=3acf7692-49cb-4c45-9943-6f3dba512dae&grant_type=client_credentials</div></li><li>鍐嶅皢姝CCESS_TOKEN浠earer TOKEN鐨勬柟寮忚皟鐢ㄥ埆鐨勭殑API</li><li>榪欏氨鏄痗lient_credentials嫻佺▼</li></ul><br />楠岃瘉Access Token鍜岃幏鍙朤oken鍏冧俊鎭細<br /><ul><li><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->http:<span style="color: #008000; ">//</span><span style="color: #008000; ">10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token/introspect</span><span style="color: #008000; "><br /></span>client_id=app-springboot-confidential&client_secret=3acf7692-49cb-4c45-9943-6f3dba512dae</div></li><li>Access Token鏃犳晥鏃惰繑鍥烇細<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->{<br />    "active": <span style="color: #0000FF; ">false</span><br />}</div></li></ul><br />鍒鋒柊Token錛?br /><ul><li><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->http:<span style="color: #008000; ">//</span><span style="color: #008000; ">10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token</span><span style="color: #008000; "><br /></span>client_id=app-springboot-confidential&client_secret=3acf7692-49cb-4c45-9943-6f3dba512dae&grant_type=refresh_token&refresh_token=asdfasd</div></li><li>榪斿洖<br /><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->{<br />    "access_token": "eyJhbGciOiJSUzI1NiIsIn",<br />    "expires_in": 300,<br />    "refresh_expires_in": 1800,<br />    "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCIgOi",<br />    "token_type": "Bearer",<br />    "not-before-policy": 1610728470,<br />    "session_state": "c1273eb5-f922-420c-b23a-854be9735c1d",<br />    "scope": "profile email"<br />}</div></li></ul><br /><br /><br />Reference:<br /><a target="_blank">https://blog.csdn.net/nklinsirui/article/details/112706006</a><br /><br /><a target="_blank">https://www.baeldung.com/?s=keycloak</a><br /><br /><a target="_blank">https://www.doag.org/formes/pubfiles/11143470/2019-NN-Sebastien_Blanc-Easily_Secure_your_Microservices_with_Keycloak-Praesentation.pdf</a><br /><br /><br /><br /><br /><img src ="http://www.aygfsteel.com/paulwong/aggbug/436009.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2021-10-12 14:40 <a href="http://www.aygfsteel.com/paulwong/archive/2021/10/12/436009.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>SPRING CLOUD JWT璧勬簮http://www.aygfsteel.com/paulwong/archive/2017/03/24/432401.htmlpaulwongpaulwongFri, 24 Mar 2017 15:11:00 GMThttp://www.aygfsteel.com/paulwong/archive/2017/03/24/432401.htmlhttp://www.aygfsteel.com/paulwong/comments/432401.htmlhttp://www.aygfsteel.com/paulwong/archive/2017/03/24/432401.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/432401.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/432401.htmlhttps://github.com/thomas-kendall/trivia-microservices


涓涓猄pring Boot錛?JWT錛孉ugularJS鎺ュ彛瀹夊叏楠岃瘉鐨勭畝鍗曚緥瀛?br />http://blog.csdn.net/offbye/article/details/47607711



https://github.com/tuanngda/spring-boot-oauth2-demo


Spring Oauth2 with JWT Sample
http://www.tuicool.com/articles/EjUFZj7


http://stackoverflow.com/questions/38156213/spring-cloud-zuul-jwt-for-value-reference-tokens

paulwong 2017-03-24 23:11 鍙戣〃璇勮
]]>
鐞嗚ВOAuth 2.0http://www.aygfsteel.com/paulwong/archive/2015/08/07/426658.htmlpaulwongpaulwongFri, 07 Aug 2015 06:12:00 GMThttp://www.aygfsteel.com/paulwong/archive/2015/08/07/426658.htmlhttp://www.aygfsteel.com/paulwong/comments/426658.htmlhttp://www.aygfsteel.com/paulwong/archive/2015/08/07/426658.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/426658.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/426658.htmlhttps://www.ruanyifeng.com/blog/2019/04/oauth-grant-types.html

https://aaronparecki.com/oauth-2-simplified


paulwong 2015-08-07 14:12 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 读书| 古蔺县| 永修县| 都兰县| 扎囊县| 新田县| 平邑县| 武鸣县| 新疆| 吉木萨尔县| 松溪县| 恩平市| 津市市| 江孜县| 武宁县| 蓬莱市| 云阳县| 会泽县| 隆德县| 大庆市| 商河县| 邵阳市| 廉江市| 上虞市| 常熟市| 青神县| 固始县| 沂源县| 谢通门县| 清河县| 蓝山县| 辽阳县| 康乐县| 屏山县| 安新县| 淄博市| 泌阳县| 三台县| 酒泉市| 长乐市| 三明市|