2016-08-25 2 views
1

액세스 토큰 (참조 액세스 토큰)을받은 후 내 API 미들웨어가 instropection 끝점을 호출하여 jwt 토큰을 가져옵니다. 유감스럽게도 json 응답에 unauthortize라는 오류 메시지가 표시됩니다.참조 토큰을 사용할 때 IdentityServer3 - ScopeSecretValidator

2016년 8월 24일 13 : 33 : 39.505 -04 : 00 [디버그] 범위 검증 2016년 8월 24일 13 시작 : 33 : 39.505 -04 : 00 [디버그] 2016- 기본 인증 비밀 파싱 시작 08-24 13 : 33 : 39.505 -04 : 00 [디버그] 파서가 비밀을 발견했습니다 : "BasicAuthenticationSecretParser" 2016-08-24 13 : 33 : 39.505 -04 : 00 [정보] 비밀 아이디가 발견되었습니다 : "webapp123.hybric.flow " 2016-08-24 13 : 33 : 39.507 -04 : 00 [정보] 해당 이름의 범위가 없습니다. aborting 2016-08-24 13 : 33 : 39.507 -04 : 00 [경고] 인트로 스펙 엔드 포인트를 호출 할 권한이없는 범위입니다. 중단.

마치 instropection 끝점에 전달 된 클라이언트 응용 프로그램 ID를 사용하여 클라이언트 응용 프로그램에서 요청한 범위를 검색하는 것처럼 보입니다. 질문 :

그 사람이 맞습니까? Id3에서 클라이언트가 요청한 범위를 기억할 수 있습니까? api ClientId를 사용하여 부목 엔드 포인트를 호출 할 수 있습니까? - 참조 토큰을 요청한 클라이언트 응용 프로그램의 클라이언트 ID를 사용하고 싶지 않습니다. 노호

번호 :.

VAR 범위 = (_scopes.FindScopesAsync 기다리고 (새 [] parsedSecret.Id {})) FirstOrDefault();

답변

0

ntrospection 끝점은 토큰의 유효성을 검사하는 것으로 Jwt를 가져 오지 않습니다. Introspection 엔드 포인트를 호출하려면 클라이언트 ID가 아닌 인증 요청에 "Scope"및 "Scope secret"를 전달해야합니다. 유효 범위 이름과 암호로 instrospection 끝점에 참조 토큰을 보내는 경우 응답에서 클레임이 표시됩니다.

public async Task ValidateValidReferenceTokenUsingIntrospectionEndPoint() 
      { 
       var tokenResponse = await GetTokenResponseForClientCredentialsFlow(IdsModel.AccessTokenType.Reference); 

       var introspectionClient = new IntrospectionClient(
        IntrospectionEndpoint, 
        "Api1", // scope name, scope secret 
        "Api1Secret"); 

       var response = await introspectionClient.SendAsync(new IntrospectionRequest 
       { 
        Token = tokenResponse.AccessToken 
       }); 

       var jsonResult = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Raw); 

       response.IsActive.Should().Be(true); 
       response.IsError.Should().Be(false); 


       jsonResult.Should().Contain("iss", ValidIssuer); 
       jsonResult.Should().Contain("aud", ValidAudience); 
       jsonResult.Should().Contain("client_id", "referenceTokenClient"); 
jsonResult.Should().Contain("client_claim1", "claim1value"); 
       jsonResult.Should().Contain("active", true); 
      } 
관련 문제