2016-08-29 2 views

답변

1

나는 지금까지 swagger swashbuckle 엔드 포인트를 확보 할 방법이 없다고 생각합니다. github 문제로 팁과 기타 사항을 얻을 수 있습니다. here

+0

문제의 링크 주셔서 감사합니다. 주어진 솔루션 아래 나를 위해 작동합니다. https://github.com/domaindrivendev/Swashbuckle/issues/384#issuecomment-111609097 –

1

이 솔루션은 솔루션에 인증을 구현 한 경우에만 작동합니다.

  1. 새로운 Web.config 파일을 추가 솔루션에 새 폴더 자신감을 만듭니다. 거기에 코드를 다음
  2. 쓰기 :

    <configuration> 
        <system.web> 
         <authorization> 
          <deny users="?" /> 
         </authorization> 
        </system.web> 
        <system.webServer> 
         <modules runAllManagedModulesForAllRequests="true" /> 
        </system.webServer> 
    </configuration> 
    
1

나는이 작업을 수행하는 방법을 알아 냈어. 최신 swashbuckle 버전을 사용하여이 인증을 위해 한번 사용될 수 자신감의 UI에서 인증 단추를 보여줄 것이다>

주입

<div ID 된 index.html = 'auth_container'에서 DIV 태그 아래에 추가 당신의 SwaggerConfig.cs 내부 https://github.com/domaindrivendev/Swashbuckle/issues/601

0

을 - 인증, API에 대한 모든 요청 들어, JWT 토큰이

또한 자신감의 UI에서 통과 될 것이라고 자신감의 문서에 대한 모든 호출을 보호하기 위해 아래 링크를 따라 파일을 만족 시키려면 다음 코드를 주석 해제하십시오. 보안 요구.

    // You can use "BasicAuth", "ApiKey" or "OAuth2" options to describe security schemes for the 
        // See https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md for more details. 
        // NOTE: These only define the schemes and need to be coupled with a corresponding "security" property 
        // at the document or operation level to indicate which schemes are required for an operation. To do this, 
        // you'll need to implement a custom IDocumentFilter and/or IOperationFilter to set these properties 
        // according to your specific authorization implementation 
        // 
        c.BasicAuth("basic") 
         .Description("Basic HTTP Authentication"); 
        // 
        // NOTE: You must also configure 'EnableApiKeySupport' below in the SwaggerUI section 
        //c.ApiKey("apiKey") 
        // .Description("API Key Authentication") 
        // .Name("apiKey") 
        // .In("header"); 
        // 
        //c.OAuth2("oauth2") 
        // .Description("OAuth2 Implicit Grant") 
        // .Flow("implicit") 
        // .AuthorizationUrl("http://petstore.swagger.wordnik.com/api/oauth/dialog") 
        // //.TokenUrl("https://tempuri.org/token") 
        // .Scopes(scopes => 
        // { 
        //  scopes.Add("read", "Read access to protected resources"); 
        //  scopes.Add("write", "Write access to protected resources"); 
        // }); 
관련 문제