diff --git a/springdoc-openapi-security/pom.xml b/springdoc-openapi-security/pom.xml index bede3b86d..315683636 100644 --- a/springdoc-openapi-security/pom.xml +++ b/springdoc-openapi-security/pom.xml @@ -4,7 +4,7 @@ springdoc-openapi org.springdoc - 1.6.15-SNAPSHOT + 1.6.16-SNAPSHOT springdoc-openapi-security @@ -79,4 +79,4 @@ - \ No newline at end of file + diff --git a/springdoc-openapi-security/src/main/java/org/springdoc/security/SpringDocSecurityOAuth2Customizer.java b/springdoc-openapi-security/src/main/java/org/springdoc/security/SpringDocSecurityOAuth2Customizer.java index 9c9b44b75..1c96154c9 100644 --- a/springdoc-openapi-security/src/main/java/org/springdoc/security/SpringDocSecurityOAuth2Customizer.java +++ b/springdoc-openapi-security/src/main/java/org/springdoc/security/SpringDocSecurityOAuth2Customizer.java @@ -2,13 +2,14 @@ import java.lang.reflect.Field; -import com.nimbusds.jose.jwk.JWKSet; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.headers.Header; +import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.MapSchema; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; @@ -23,6 +24,7 @@ import org.springdoc.core.SpringDocAnnotationsUtils; import org.springdoc.core.customizers.GlobalOpenApiCustomizer; import org.springdoc.security.oauth2.SpringDocOAuth2AuthorizationServerMetadata; +import org.springdoc.security.oauth2.SpringDocOAuth2Token; import org.springdoc.security.oauth2.SpringDocOAuth2TokenIntrospection; import org.springframework.beans.BeansException; @@ -31,10 +33,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.security.oauth2.core.OAuth2Error; -import org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse; import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames; -import org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationConsentAuthenticationToken; -import org.springframework.security.oauth2.server.authorization.authentication.OAuth2TokenRevocationAuthenticationToken; import org.springframework.security.oauth2.server.authorization.web.NimbusJwkSetEndpointFilter; import org.springframework.security.oauth2.server.authorization.web.OAuth2AuthorizationEndpointFilter; import org.springframework.security.oauth2.server.authorization.web.OAuth2AuthorizationServerMetadataEndpointFilter; @@ -49,6 +48,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.http.MediaType.TEXT_HTML_VALUE; /** * The type Spring doc security o auth 2 customizer. @@ -95,7 +95,10 @@ private void getOAuth2TokenRevocationEndpointFilter(OpenAPI openAPI, SecurityFil Object oAuth2EndpointFilter = new SpringDocSecurityOAuth2EndpointUtils(OAuth2TokenRevocationEndpointFilter.class).findEndpoint(securityFilterChain); if (oAuth2EndpointFilter != null) { - ApiResponses apiResponses = buildApiResponsesWithBadRequest(SpringDocAnnotationsUtils.resolveSchemaFromType(OAuth2TokenRevocationAuthenticationToken.class, openAPI.getComponents(), null), openAPI); + ApiResponses apiResponses = new ApiResponses(); + apiResponses.addApiResponse(String.valueOf(HttpStatus.OK.value()), new ApiResponse().description(HttpStatus.OK.getReasonPhrase())); + buildApiResponsesOnInternalServerError(apiResponses); + buildApiResponsesOnBadRequest(apiResponses, openAPI); Operation operation = buildOperation(apiResponses); Schema schema = new ObjectSchema() @@ -119,15 +122,19 @@ private void getOAuth2TokenIntrospectionEndpointFilter(OpenAPI openAPI, Security Object oAuth2EndpointFilter = new SpringDocSecurityOAuth2EndpointUtils(OAuth2TokenIntrospectionEndpointFilter.class).findEndpoint(securityFilterChain); if (oAuth2EndpointFilter != null) { - ApiResponses apiResponses = buildApiResponsesWithBadRequest(SpringDocAnnotationsUtils.resolveSchemaFromType(SpringDocOAuth2TokenIntrospection.class, openAPI.getComponents(), null), openAPI); + ApiResponses apiResponses = new ApiResponses(); + buildApiResponsesOnSuccess(apiResponses, SpringDocAnnotationsUtils.resolveSchemaFromType(SpringDocOAuth2TokenIntrospection.class, openAPI.getComponents(), null)); + buildApiResponsesOnInternalServerError(apiResponses); + buildApiResponsesOnBadRequest(apiResponses, openAPI); + Operation operation = buildOperation(apiResponses); - Schema schema = new ObjectSchema() + Schema requestSchema = new ObjectSchema() .addProperty("token", new StringSchema()) .addProperty(OAuth2ParameterNames.TOKEN_TYPE_HINT, new StringSchema()) .addProperty("additionalParameters", new ObjectSchema().additionalProperties(new StringSchema())); String mediaType = org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; - RequestBody requestBody = new RequestBody().content(new Content().addMediaType(mediaType, new MediaType().schema(schema))); + RequestBody requestBody = new RequestBody().content(new Content().addMediaType(mediaType, new MediaType().schema(requestSchema))); operation.setRequestBody(requestBody); buildPath(oAuth2EndpointFilter, "tokenIntrospectionEndpointMatcher", openAPI, operation, HttpMethod.POST); } @@ -143,7 +150,9 @@ private void getOAuth2AuthorizationServerMetadataEndpoint(OpenAPI openAPI, Secur Object oAuth2EndpointFilter = new SpringDocSecurityOAuth2EndpointUtils(OAuth2AuthorizationServerMetadataEndpointFilter.class).findEndpoint(securityFilterChain); if (oAuth2EndpointFilter != null) { - ApiResponses apiResponses = buildApiResponses(SpringDocAnnotationsUtils.resolveSchemaFromType(SpringDocOAuth2AuthorizationServerMetadata.class, openAPI.getComponents(), null)); + ApiResponses apiResponses = new ApiResponses(); + buildApiResponsesOnSuccess(apiResponses, SpringDocAnnotationsUtils.resolveSchemaFromType(SpringDocOAuth2AuthorizationServerMetadata.class, openAPI.getComponents(), null)); + buildApiResponsesOnInternalServerError(apiResponses); Operation operation = buildOperation(apiResponses); buildPath(oAuth2EndpointFilter, "requestMatcher", openAPI, operation, HttpMethod.GET); } @@ -159,7 +168,17 @@ private void getNimbusJwkSetEndpoint(OpenAPI openAPI, SecurityFilterChain securi Object oAuth2EndpointFilter = new SpringDocSecurityOAuth2EndpointUtils(NimbusJwkSetEndpointFilter.class).findEndpoint(securityFilterChain); if (oAuth2EndpointFilter != null) { - ApiResponses apiResponses = buildApiResponses(SpringDocAnnotationsUtils.resolveSchemaFromType(JWKSet.class, openAPI.getComponents(), null)); + ApiResponses apiResponses = new ApiResponses(); + Schema schema = new MapSchema(); + schema.addProperty("keys", new ArraySchema().items(new ObjectSchema().additionalProperties(true))); + + ApiResponse response = new ApiResponse().description(HttpStatus.OK.getReasonPhrase()).content(new Content().addMediaType( + APPLICATION_JSON_VALUE, + new MediaType().schema(schema))); + apiResponses.addApiResponse(String.valueOf(HttpStatus.OK.value()), response); + buildApiResponsesOnInternalServerError(apiResponses); + buildApiResponsesOnBadRequest(apiResponses, openAPI); + Operation operation = buildOperation(apiResponses); operation.responses(apiResponses); buildPath(oAuth2EndpointFilter, "requestMatcher", openAPI, operation, HttpMethod.GET); @@ -177,7 +196,10 @@ private void getOAuth2TokenEndpoint(OpenAPI openAPI, SecurityFilterChain securit new SpringDocSecurityOAuth2EndpointUtils(OAuth2TokenEndpointFilter.class).findEndpoint(securityFilterChain); if (oAuth2EndpointFilter != null) { - ApiResponses apiResponses = buildApiResponsesWithBadRequest(SpringDocAnnotationsUtils.resolveSchemaFromType(OAuth2AccessTokenResponse.class, openAPI.getComponents(), null), openAPI); + ApiResponses apiResponses = new ApiResponses(); + buildApiResponsesOnSuccess(apiResponses, SpringDocAnnotationsUtils.resolveSchemaFromType(SpringDocOAuth2Token.class, openAPI.getComponents(), null)); + buildApiResponsesOnInternalServerError(apiResponses); + buildApiResponsesOnBadRequest(apiResponses, openAPI); buildOAuth2Error(openAPI, apiResponses, HttpStatus.UNAUTHORIZED); Operation operation = buildOperation(apiResponses); Schema schema = new ObjectSchema().additionalProperties(new StringSchema()); @@ -196,7 +218,14 @@ private void getOAuth2AuthorizationEndpoint(OpenAPI openAPI, SecurityFilterChain Object oAuth2EndpointFilter = new SpringDocSecurityOAuth2EndpointUtils(OAuth2AuthorizationEndpointFilter.class).findEndpoint(securityFilterChain); if (oAuth2EndpointFilter != null) { - ApiResponses apiResponses = buildApiResponsesWithBadRequest(SpringDocAnnotationsUtils.resolveSchemaFromType(OAuth2AuthorizationConsentAuthenticationToken.class, openAPI.getComponents(), null), openAPI); + ApiResponses apiResponses = new ApiResponses(); + + ApiResponse response = new ApiResponse().description(HttpStatus.OK.getReasonPhrase()).content(new Content().addMediaType( + TEXT_HTML_VALUE, + new MediaType())); + apiResponses.addApiResponse(String.valueOf(HttpStatus.OK.value()), response); + buildApiResponsesOnInternalServerError(apiResponses); + buildApiResponsesOnBadRequest(apiResponses, openAPI); apiResponses.addApiResponse(String.valueOf(HttpStatus.MOVED_TEMPORARILY.value()), new ApiResponse().description(HttpStatus.MOVED_TEMPORARILY.getReasonPhrase()) .addHeaderObject("Location", new Header().schema(new StringSchema()))); @@ -221,30 +250,39 @@ private Operation buildOperation(ApiResponses apiResponses) { } /** - * Build api responses api responses. + * Build api responses api responses on success. * + * @param apiResponses the api responses * @param schema the schema * @return the api responses */ - private ApiResponses buildApiResponses(Schema schema) { - ApiResponses apiResponses = new ApiResponses(); + private ApiResponses buildApiResponsesOnSuccess(ApiResponses apiResponses, Schema schema) { ApiResponse response = new ApiResponse().description(HttpStatus.OK.getReasonPhrase()).content(new Content().addMediaType( APPLICATION_JSON_VALUE, new MediaType().schema(schema))); apiResponses.addApiResponse(String.valueOf(HttpStatus.OK.value()), response); + return apiResponses; + } + + /** + * Build api responses api responses on internal server error. + * + * @param apiResponses the api responses + * @return the api responses + */ + private ApiResponses buildApiResponsesOnInternalServerError(ApiResponses apiResponses) { apiResponses.addApiResponse(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()), new ApiResponse().description(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase())); return apiResponses; } /** - * Build api responses with bad request api responses. + * Build api responses on bad request. * - * @param schema the schema + * @param apiResponses the api responses * @param openAPI the open api * @return the api responses */ - private ApiResponses buildApiResponsesWithBadRequest(Schema schema, OpenAPI openAPI) { - ApiResponses apiResponses = buildApiResponses(schema); + private ApiResponses buildApiResponsesOnBadRequest(ApiResponses apiResponses, OpenAPI openAPI) { buildOAuth2Error(openAPI, apiResponses, HttpStatus.BAD_REQUEST); return apiResponses; } diff --git a/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2AuthorizationServerMetadata.java b/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2AuthorizationServerMetadata.java index b919dbce3..584b1e08c 100644 --- a/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2AuthorizationServerMetadata.java +++ b/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2AuthorizationServerMetadata.java @@ -1,154 +1,54 @@ package org.springdoc.security.oauth2; -import java.net.URL; -import java.time.Instant; import java.util.List; -import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationServerMetadataClaimAccessor; import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationServerMetadataClaimNames; /** + * The type Spring doc o auth 2 authorization server metadata. + * + * @see OAuth2AuthorizationServerMetadata * @author bnasslahsen + * @author yuta.saito */ @Schema(name = "OAuth2AuthorizationServerMetadata") -public class SpringDocOAuth2AuthorizationServerMetadata implements OAuth2AuthorizationServerMetadataClaimAccessor { - - - @Override - public Map getClaims() { - return null; - } - - @Override - public T getClaim(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClaim(claim); - } - - @Override - public boolean hasClaim(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.hasClaim(claim); - } - - @Override - public Boolean containsClaim(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.containsClaim(claim); - } - - @Override - public String getClaimAsString(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClaimAsString(claim); - } - - @Override - public Boolean getClaimAsBoolean(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClaimAsBoolean(claim); - } - - @Override - public Instant getClaimAsInstant(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClaimAsInstant(claim); - } - - @Override - public URL getClaimAsURL(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClaimAsURL(claim); - } - - @Override - public Map getClaimAsMap(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClaimAsMap(claim); - } - - @Override - public List getClaimAsStringList(String claim) { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClaimAsStringList(claim); - } - - @Override +public interface SpringDocOAuth2AuthorizationServerMetadata { @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.ISSUER) - public URL getIssuer() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getIssuer(); - } + String issuer(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.AUTHORIZATION_ENDPOINT) - public URL getAuthorizationEndpoint() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getAuthorizationEndpoint(); - } + String authorizationEndpoint(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT) - public URL getTokenEndpoint() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getTokenEndpoint(); - } + String tokenEndpoint(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED) - public List getTokenEndpointAuthenticationMethods() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getTokenEndpointAuthenticationMethods(); - } + List tokenEndpointAuthMethodsSupported(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.JWKS_URI) - public URL getJwkSetUrl() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getJwkSetUrl(); - } - - @Override - @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.SCOPES_SUPPORTED) - public List getScopes() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getScopes(); - } + String jwksUri(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED) - public List getResponseTypes() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getResponseTypes(); - } + List responseTypesSupported(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.GRANT_TYPES_SUPPORTED) - public List getGrantTypes() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getGrantTypes(); - } + List grantTypesSupported(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT) - public URL getTokenRevocationEndpoint() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getTokenRevocationEndpoint(); - } + String revocationEndpoint(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED) - public List getTokenRevocationEndpointAuthenticationMethods() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getTokenRevocationEndpointAuthenticationMethods(); - } + List revocationEndpointAuthMethodsSupported(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT) - public URL getTokenIntrospectionEndpoint() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getTokenIntrospectionEndpoint(); - } + String introspectionEndpoint(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED) - public List getTokenIntrospectionEndpointAuthenticationMethods() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getTokenIntrospectionEndpointAuthenticationMethods(); - } - - @Override - @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.REGISTRATION_ENDPOINT) - public URL getClientRegistrationEndpoint() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getClientRegistrationEndpoint(); - } + List introspectionEndpointAuthMethodsSupported(); - @Override @JsonProperty(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED) - public List getCodeChallengeMethods() { - return OAuth2AuthorizationServerMetadataClaimAccessor.super.getCodeChallengeMethods(); - } + List codeChallengeMethodsSupported(); } diff --git a/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2Token.java b/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2Token.java new file mode 100644 index 000000000..6eb299cd4 --- /dev/null +++ b/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2Token.java @@ -0,0 +1,25 @@ +package org.springdoc.security.oauth2; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Spring doc o auth 2 token. + * + * @see DefaultOAuth2AccessTokenResponseMapConverter + * @author yuta.saito + */ +@Schema(name = "OAuth2Token") +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public interface SpringDocOAuth2Token { + String getAccessToken(); + + String getTokenType(); + + long getExpiresIn(); + + String getScope(); + + String getRefreshToken(); +} diff --git a/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2TokenIntrospection.java b/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2TokenIntrospection.java index e6a4430f2..5916933b7 100644 --- a/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2TokenIntrospection.java +++ b/springdoc-openapi-security/src/main/java/org/springdoc/security/oauth2/SpringDocOAuth2TokenIntrospection.java @@ -1,141 +1,55 @@ package org.springdoc.security.oauth2; -import java.net.URL; -import java.time.Instant; import java.util.List; -import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.security.oauth2.core.OAuth2TokenIntrospectionClaimAccessor; import org.springframework.security.oauth2.core.OAuth2TokenIntrospectionClaimNames; /** + * The type Spring doc o auth 2 token introspection. + * + * @see OAuth2TokenIntrospectionHttpMessageConverter + * @see OAuth2TokenIntrospection * @author bnasslahsen + * @author yuta.saito */ @Schema(name = "OAuth2TokenIntrospection") -public class SpringDocOAuth2TokenIntrospection implements OAuth2TokenIntrospectionClaimAccessor { - - @Override - public Map getClaims() { - return null; - } - - @Override - public T getClaim(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.getClaim(claim); - } - - @Override - public boolean hasClaim(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.hasClaim(claim); - } - - @Override - public Boolean containsClaim(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.containsClaim(claim); - } - - @Override - public String getClaimAsString(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.getClaimAsString(claim); - } - - @Override - public Boolean getClaimAsBoolean(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.getClaimAsBoolean(claim); - } - - @Override - public Instant getClaimAsInstant(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.getClaimAsInstant(claim); - } - - @Override - public URL getClaimAsURL(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.getClaimAsURL(claim); - } - - @Override - public Map getClaimAsMap(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.getClaimAsMap(claim); - } - - @Override - public List getClaimAsStringList(String claim) { - return OAuth2TokenIntrospectionClaimAccessor.super.getClaimAsStringList(claim); - } - - @Override +public interface SpringDocOAuth2TokenIntrospection { @JsonProperty(OAuth2TokenIntrospectionClaimNames.ACTIVE) - public boolean isActive() { - return OAuth2TokenIntrospectionClaimAccessor.super.isActive(); - } + boolean getActive(); - @Override - @JsonProperty(OAuth2TokenIntrospectionClaimNames.USERNAME) - public String getUsername() { - return OAuth2TokenIntrospectionClaimAccessor.super.getUsername(); - } + @JsonProperty(OAuth2TokenIntrospectionClaimNames.SCOPE) + String getScope(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.CLIENT_ID) - public String getClientId() { - return OAuth2TokenIntrospectionClaimAccessor.super.getClientId(); - } + String getClientId(); - @Override - @JsonProperty(OAuth2TokenIntrospectionClaimNames.SCOPE) - public List getScopes() { - return OAuth2TokenIntrospectionClaimAccessor.super.getScopes(); - } + @JsonProperty(OAuth2TokenIntrospectionClaimNames.USERNAME) + String getUsername(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.TOKEN_TYPE) - public String getTokenType() { - return OAuth2TokenIntrospectionClaimAccessor.super.getTokenType(); - } + String getTokenType(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.EXP) - public Instant getExpiresAt() { - return OAuth2TokenIntrospectionClaimAccessor.super.getExpiresAt(); - } + long getExpiresAt(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.IAT) - public Instant getIssuedAt() { - return OAuth2TokenIntrospectionClaimAccessor.super.getIssuedAt(); - } + long getIssueAt(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.NBF) - public Instant getNotBefore() { - return OAuth2TokenIntrospectionClaimAccessor.super.getNotBefore(); - } + long getNotBefore(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.SUB) - public String getSubject() { - return OAuth2TokenIntrospectionClaimAccessor.super.getSubject(); - } + String getSubject(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.AUD) - public List getAudience() { - return OAuth2TokenIntrospectionClaimAccessor.super.getAudience(); - } + List getAudience(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.ISS) - public URL getIssuer() { - return OAuth2TokenIntrospectionClaimAccessor.super.getIssuer(); - } + String getIssuer(); - @Override @JsonProperty(OAuth2TokenIntrospectionClaimNames.JTI) - public String getId() { - return OAuth2TokenIntrospectionClaimAccessor.super.getId(); - } + String getId(); } diff --git a/springdoc-openapi-security/src/test/resources/results/app10.json b/springdoc-openapi-security/src/test/resources/results/app10.json index af11778c1..af7b71c19 100644 --- a/springdoc-openapi-security/src/test/resources/results/app10.json +++ b/springdoc-openapi-security/src/test/resources/results/app10.json @@ -42,7 +42,26 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/JWKSet" + "type": "object", + "properties": { + "keys": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + } + } + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" } } } @@ -98,14 +117,11 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OAuth2AccessTokenResponse" + "$ref": "#/components/schemas/OAuth2Token" } } } }, - "500": { - "description": "Internal Server Error" - }, "400": { "description": "Bad Request", "content": { @@ -125,6 +141,9 @@ } } } + }, + "500": { + "description": "Internal Server Error" } } } @@ -150,16 +169,19 @@ "200": { "description": "OK", "content": { - "application/json": { + "text/html": {} + } + }, + "302": { + "description": "Moved Temporarily", + "headers": { + "Location": { "schema": { "type": "string" } } } }, - "500": { - "description": "Internal Server Error" - }, "400": { "description": "Bad Request", "content": { @@ -170,15 +192,8 @@ } } }, - "302": { - "description": "Moved Temporarily", - "headers": { - "Location": { - "schema": { - "type": "string" - } - } - } + "500": { + "description": "Internal Server Error" } } } @@ -222,9 +237,6 @@ } } }, - "500": { - "description": "Internal Server Error" - }, "400": { "description": "Bad Request", "content": { @@ -234,6 +246,9 @@ } } } + }, + "500": { + "description": "Internal Server Error" } } } @@ -262,17 +277,7 @@ }, "responses": { "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - }, - "500": { - "description": "Internal Server Error" + "description": "OK" }, "400": { "description": "Bad Request", @@ -283,6 +288,9 @@ } } } + }, + "500": { + "description": "Internal Server Error" } } } @@ -290,322 +298,16 @@ }, "components": { "schemas": { - "Algorithm": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "requirement": { - "type": "string", - "enum": [ - "REQUIRED", - "RECOMMENDED", - "OPTIONAL" - ] - } - } - }, - "Base64": { - "type": "object" - }, - "Base64URL": { - "type": "object" - }, - "JWK": { + "OAuth2Error": { "type": "object", "properties": { - "keyStore": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "provider": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "private": { - "type": "boolean" - }, - "algorithm": { - "$ref": "#/components/schemas/Algorithm" - }, - "x509CertURL": { - "type": "string", - "format": "uri" - }, - "keyOperations": { - "uniqueItems": true, - "type": "array", - "items": { - "type": "string", - "enum": [ - "sign", - "verify", - "encrypt", - "decrypt", - "wrapKey", - "unwrapKey", - "deriveKey", - "deriveBits" - ] - } - }, - "x509CertThumbprint": { - "$ref": "#/components/schemas/Base64URL" - }, - "requiredParams": { - "type": "object", - "additionalProperties": { - "type": "object" - } - }, - "parsedX509CertChain": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "subjectX500Principal": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "encoded": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - } - } - }, - "issuerX500Principal": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "encoded": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - } - } - }, - "extendedKeyUsage": { - "type": "array", - "items": { - "type": "string" - } - }, - "subjectAlternativeNames": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "object" - } - } - }, - "issuerAlternativeNames": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "object" - } - } - }, - "sigAlgParams": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - }, - "tbscertificate": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - }, - "sigAlgOID": { - "type": "string" - }, - "issuerUniqueID": { - "type": "array", - "items": { - "type": "boolean" - } - }, - "subjectUniqueID": { - "type": "array", - "items": { - "type": "boolean" - } - }, - "sigAlgName": { - "type": "string" - }, - "subjectDN": { - "type": "object", - "properties": { - "name": { - "type": "string" - } - } - }, - "issuerDN": { - "type": "object", - "properties": { - "name": { - "type": "string" - } - } - }, - "notBefore": { - "type": "string", - "format": "date-time" - }, - "notAfter": { - "type": "string", - "format": "date-time" - }, - "signature": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - }, - "basicConstraints": { - "type": "integer", - "format": "int32" - }, - "version": { - "type": "integer", - "format": "int32" - }, - "serialNumber": { - "type": "integer" - }, - "keyUsage": { - "type": "array", - "items": { - "type": "boolean" - } - }, - "criticalExtensionOIDs": { - "uniqueItems": true, - "type": "array", - "items": { - "type": "string" - } - }, - "nonCriticalExtensionOIDs": { - "uniqueItems": true, - "type": "array", - "items": { - "type": "string" - } - }, - "encoded": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - }, - "publicKey": { - "type": "object", - "properties": { - "encoded": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - } - }, - "format": { - "type": "string" - }, - "algorithm": { - "type": "string" - } - } - } - } - } - }, - "x509CertChain": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Base64" - } - }, - "keyType": { - "$ref": "#/components/schemas/KeyType" - }, - "keyUse": { - "$ref": "#/components/schemas/KeyUse" - }, - "keyID": { + "errorCode": { "type": "string" }, - "x509CertSHA256Thumbprint": { - "$ref": "#/components/schemas/Base64URL" - } - } - }, - "JWKSet": { - "type": "object", - "properties": { - "keys": { - "type": "array", - "items": { - "$ref": "#/components/schemas/JWK" - } - }, - "additionalMembers": { - "type": "object", - "additionalProperties": { - "type": "object" - } - } - } - }, - "KeyType": { - "type": "object", - "properties": { - "value": { + "description": { "type": "string" }, - "requirement": { - "type": "string", - "enum": [ - "REQUIRED", - "RECOMMENDED", - "OPTIONAL" - ] - } - } - }, - "KeyUse": { - "type": "object", - "properties": { - "value": { + "uri": { "type": "string" } } @@ -613,43 +315,22 @@ "OAuth2AuthorizationServerMetadata": { "type": "object", "properties": { - "claims": { - "type": "object", - "additionalProperties": { - "type": "object" - } - }, - "revocation_endpoint_auth_methods_supported": { - "type": "array", - "items": { - "type": "string" - } + "issuer": { + "type": "string" }, - "introspection_endpoint_auth_methods_supported": { + "token_endpoint_auth_methods_supported": { "type": "array", "items": { "type": "string" } }, - "authorization_endpoint": { - "type": "string", - "format": "url" - }, - "token_endpoint": { - "type": "string", - "format": "url" - }, - "revocation_endpoint": { - "type": "string", - "format": "url" - }, - "response_types_supported": { + "revocation_endpoint_auth_methods_supported": { "type": "array", "items": { "type": "string" } }, - "grant_types_supported": { + "introspection_endpoint_auth_methods_supported": { "type": "array", "items": { "type": "string" @@ -661,113 +342,52 @@ "type": "string" } }, - "jwks_uri": { - "type": "string", - "format": "url" + "authorization_endpoint": { + "type": "string" + }, + "token_endpoint": { + "type": "string" }, - "scopes_supported": { + "response_types_supported": { "type": "array", "items": { "type": "string" } }, - "issuer": { - "type": "string", - "format": "url" - }, - "introspection_endpoint": { - "type": "string", - "format": "url" - }, - "token_endpoint_auth_methods_supported": { + "grant_types_supported": { "type": "array", "items": { "type": "string" } }, - "registration_endpoint": { - "type": "string", - "format": "url" - } - } - }, - "OAuth2AccessToken": { - "type": "object", - "properties": { - "tokenValue": { + "revocation_endpoint": { "type": "string" }, - "issuedAt": { - "type": "string", - "format": "date-time" - }, - "expiresAt": { - "type": "string", - "format": "date-time" - }, - "tokenType": { - "$ref": "#/components/schemas/TokenType" - }, - "scopes": { - "uniqueItems": true, - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "OAuth2AccessTokenResponse": { - "type": "object", - "properties": { - "accessToken": { - "$ref": "#/components/schemas/OAuth2AccessToken" - }, - "refreshToken": { - "$ref": "#/components/schemas/OAuth2RefreshToken" + "introspection_endpoint": { + "type": "string" }, - "additionalParameters": { - "type": "object", - "additionalProperties": { - "type": "object" - } + "jwks_uri": { + "type": "string" } } }, - "OAuth2RefreshToken": { + "OAuth2Token": { "type": "object", "properties": { - "tokenValue": { + "scope": { "type": "string" }, - "issuedAt": { - "type": "string", - "format": "date-time" + "expires_in": { + "type": "integer", + "format": "int64" }, - "expiresAt": { - "type": "string", - "format": "date-time" - } - } - }, - "TokenType": { - "type": "object", - "properties": { - "value": { - "type": "string" - } - } - }, - "OAuth2Error": { - "type": "object", - "properties": { - "errorCode": { + "access_token": { "type": "string" }, - "description": { + "refresh_token": { "type": "string" }, - "uri": { + "token_type": { "type": "string" } } @@ -775,21 +395,15 @@ "OAuth2TokenIntrospection": { "type": "object", "properties": { - "claims": { - "type": "object", - "additionalProperties": { - "type": "object" - } - }, "nbf": { - "type": "string", - "format": "date-time" + "type": "integer", + "format": "int64" }, - "jti": { + "scope": { "type": "string" }, - "active": { - "type": "boolean" + "jti": { + "type": "string" }, "client_id": { "type": "string" @@ -797,15 +411,10 @@ "username": { "type": "string" }, - "iat": { - "type": "string", - "format": "date-time" - }, - "exp": { - "type": "string", - "format": "date-time" + "active": { + "type": "boolean" }, - "token_type": { + "iss": { "type": "string" }, "aud": { @@ -814,18 +423,19 @@ "type": "string" } }, - "scope": { - "type": "array", - "items": { - "type": "string" - } + "token_type": { + "type": "string" }, - "iss": { - "type": "string", - "format": "url" + "exp": { + "type": "integer", + "format": "int64" }, "sub": { "type": "string" + }, + "iat": { + "type": "integer", + "format": "int64" } } }