{"action":"created","issue":{"url":"https://api.github.com/repos/springfox/springfox/issues/1891","repository_url":"https://api.github.com/repos/springfox/springfox","labels_url":"https://api.github.com/repos/springfox/springfox/issues/1891/labels{/name}","comments_url":"https://api.github.com/repos/springfox/springfox/issues/1891/comments","events_url":"https://api.github.com/repos/springfox/springfox/issues/1891/events","html_url":"https://github.com/springfox/springfox/issues/1891","id":239229211,"node_id":"MDU6SXNzdWUyMzkyMjkyMTE=","number":1891,"title":"Swagger2 UI - how to by pass oAuth2 configuration","user":{"login":"KpGitHub04","id":20608966,"node_id":"MDQ6VXNlcjIwNjA4OTY2","avatar_url":"https://avatars3.githubusercontent.com/u/20608966?v=4","gravatar_id":"","url":"https://api.github.com/users/KpGitHub04","html_url":"https://github.com/KpGitHub04","followers_url":"https://api.github.com/users/KpGitHub04/followers","following_url":"https://api.github.com/users/KpGitHub04/following{/other_user}","gists_url":"https://api.github.com/users/KpGitHub04/gists{/gist_id}","starred_url":"https://api.github.com/users/KpGitHub04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KpGitHub04/subscriptions","organizations_url":"https://api.github.com/users/KpGitHub04/orgs","repos_url":"https://api.github.com/users/KpGitHub04/repos","events_url":"https://api.github.com/users/KpGitHub04/events{/privacy}","received_events_url":"https://api.github.com/users/KpGitHub04/received_events","type":"User","site_admin":false},"labels":[{"id":4478206,"node_id":"MDU6TGFiZWw0NDc4MjA2","url":"https://api.github.com/repos/springfox/springfox/labels/question","name":"question","color":"bfe5bf","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/springfox/springfox/milestones/41","html_url":"https://github.com/springfox/springfox/milestone/41","labels_url":"https://api.github.com/repos/springfox/springfox/milestones/41/labels","id":2559692,"node_id":"MDk6TWlsZXN0b25lMjU1OTY5Mg==","number":41,"title":"2.8.0","description":"","creator":{"login":"dilipkrish","id":73257,"node_id":"MDQ6VXNlcjczMjU3","avatar_url":"https://avatars2.githubusercontent.com/u/73257?v=4","gravatar_id":"","url":"https://api.github.com/users/dilipkrish","html_url":"https://github.com/dilipkrish","followers_url":"https://api.github.com/users/dilipkrish/followers","following_url":"https://api.github.com/users/dilipkrish/following{/other_user}","gists_url":"https://api.github.com/users/dilipkrish/gists{/gist_id}","starred_url":"https://api.github.com/users/dilipkrish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilipkrish/subscriptions","organizations_url":"https://api.github.com/users/dilipkrish/orgs","repos_url":"https://api.github.com/users/dilipkrish/repos","events_url":"https://api.github.com/users/dilipkrish/events{/privacy}","received_events_url":"https://api.github.com/users/dilipkrish/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":293,"state":"closed","created_at":"2017-06-03T12:00:17Z","updated_at":"2018-04-11T01:23:27Z","due_on":"2017-08-01T07:00:00Z","closed_at":"2018-01-14T23:10:58Z"},"comments":9,"created_at":"2017-06-28T16:55:31Z","updated_at":"2019-04-05T19:38:05Z","closed_at":"2018-01-14T21:59:16Z","author_association":"NONE","body":"Hi experts,\r\nam facing an issue in my application. i have enabled oauth for my spring boot project ( rest service). i have created a rest client to access the oauth enabled api. \r\nwhen i load my swaggerui ( 2.5 version) \r\n```json\r\n{\r\n  \"error\": \"unauthorized\",\r\n  \"error_description\": \"Full authentication is required to access this resource\"\r\n}\r\n```\r\n\r\nif i hit the end point via post man it works. because post man is a nice tool where i can enter bearer token and invoke the service. \r\n\r\n```java\r\n@EnableResourceServer\r\n@Configuration\r\n@Component\r\npublic class ResourceServerConfiguration extends ResourceServerConfigurerAdapter\r\n{\r\n    // default url used by the resource server to check if the incoming toekn is\r\n    // valid\r\n    @Value(\"${resource.token.clientUrl}\")\r\n    private String clientUrl;\r\n \r\n    @Value(\"${resource.token.id}\")\r\n    private String resourceId;\r\n\r\n    @Value(\"${resource.token.clientId}\")\r\n    private String clientId;\r\n\r\n    @Value(\"${resource.token.clientSecret}\")\r\n    private String clientSecret;\r\n\r\n    @Bean\r\n    public RemoteTokenServices remoteTokenServices()\r\n    {\r\n        final RemoteTokenServices tokenServices = new RemoteTokenServices();\r\n        tokenServices.setCheckTokenEndpointUrl(clientUrl);\r\n        tokenServices.setClientId(clientId);\r\n        tokenServices.setClientSecret(clientSecret);\r\n        tokenServices.setAccessTokenConverter(new JwtAccessTokenConverter());\r\n        return tokenServices;\r\n    }\r\n\r\n    @Override\r\n    public void configure(ResourceServerSecurityConfigurer resources) throws Exception\r\n    {\r\n        resources.tokenServices(remoteTokenServices()).resourceId(resourceId);\r\n    }\r\n\r\n\r\n    /**\r\n     * this section can be modified to suit your service's url patterns if need\r\n     * be. this default config will allow for swagger resources to be\r\n     * un-protected, while everything else requires 'myapp.read' authority\r\n     */\r\n    @Override\r\n    public void configure(HttpSecurity http) throws Exception\r\n    {\r\n        http.csrf().disable().antMatcher(\"/**\") // this will apply to the entire\r\n                                                // web server\r\n                .authorizeRequests()\r\n                .antMatchers(\"/v2/api-docs\", \"/configuration/ui\", \"/swagger-resources\", \"/configuration/security\",\r\n                        \"/swagger-ui.html\", \"/webjars/**\", \"/swagger-resources/configuration/ui\", \"/swagger-ui.html\",\r\n                        \"/swagger-resources/configuration/security\")\r\n                .permitAll() // this\r\n                .antMatchers(HttpMethod.GET, \"/**\").access(\"#oauth2.hasScope('myapp.read')\").anyRequest()\r\n                .authenticated();\r\n\r\n    }\r\n```\r\n\r\nPlease guide me with the right configuration which will enable me to access the application through swagger UI as well. we test our application via swagger most of the times. \r\n\r\nif i remove the `   .antMatchers(HttpMethod.GET, \"/**\").access(\"#oauth2.hasScope('myapp.read')\").anyRequest()\r\n                .authenticated();` able to hit the service with out any authentication. my scope is to enable a REST APP with oauth enabled and test via swagger2."},"comment":{"url":"https://api.github.com/repos/springfox/springfox/issues/comments/480397889","html_url":"https://github.com/springfox/springfox/issues/1891#issuecomment-480397889","issue_url":"https://api.github.com/repos/springfox/springfox/issues/1891","id":480397889,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4MDM5Nzg4OQ==","user":{"login":"celovivas","id":4675511,"node_id":"MDQ6VXNlcjQ2NzU1MTE=","avatar_url":"https://avatars1.githubusercontent.com/u/4675511?v=4","gravatar_id":"","url":"https://api.github.com/users/celovivas","html_url":"https://github.com/celovivas","followers_url":"https://api.github.com/users/celovivas/followers","following_url":"https://api.github.com/users/celovivas/following{/other_user}","gists_url":"https://api.github.com/users/celovivas/gists{/gist_id}","starred_url":"https://api.github.com/users/celovivas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/celovivas/subscriptions","organizations_url":"https://api.github.com/users/celovivas/orgs","repos_url":"https://api.github.com/users/celovivas/repos","events_url":"https://api.github.com/users/celovivas/events{/privacy}","received_events_url":"https://api.github.com/users/celovivas/received_events","type":"User","site_admin":false},"created_at":"2019-04-05T19:38:05Z","updated_at":"2019-04-05T19:38:05Z","author_association":"NONE","body":"> Sorry for the format\r\n> \r\n> ```java\r\n> @Override\r\n>     public void configure(WebSecurity web) throws Exception {\r\n>         web.ignoring().antMatchers(\"/v2/api-docs\", \"/configuration/**\", \"/swagger-resources/**\",  \"/swagger-ui.html\", \"/webjars/**\", \"/api-docs/**\");\r\n>     }\r\n> ```\r\n\r\nFor me it worked too. \r\nThanks!\r\nBut, how can I pass the token in my uri methods?"}}
{"actor":{"display_login":"celovivas"}}