Skip to content

Commit

Permalink
fix(config-api): fix for acr error handling and spec enhancement for …
Browse files Browse the repository at this point in the history
…example (#2443)

* fix(jans): config api and client api

* docs(config-api): default value for Client attribute applicationType set

* docs: fix layout #2425 (#2433)

* fix: cb ttl update sdk 3 (#2434)

* fix: CB SDK 3.x duration expiration max value can be 18 250 days

* chore: merge samples

Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>

* feat(config-api): swagger spec changes for example and fix for acr

Co-authored-by: Jose <bonustrack310@gmail.com>
Co-authored-by: Yuriy M <95305560+yuremm@users.noreply.github.com>
Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
  • Loading branch information
4 people authored Sep 22, 2022
1 parent 17187e6 commit 8113841
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@

package io.jans.configapi.rest.model;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;

public class AuthenticationMethod implements Serializable {

private static final long serialVersionUID = 1L;

@NotNull(message = "defaultAcr cannot be null or blank!")
@Size(min = 1)
private String defaultAcr;

public String getDefaultAcr() {
Expand Down
66 changes: 42 additions & 24 deletions jans-config-api/docs/jans-config-api-swagger-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,21 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/AuthenticationMethod'
examples:
Request json example:
description: Request json example
value:
id: basic
externalValue: swagger/defaultAcr.json
responses:
"200":
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/AuthenticationMethod'
"400":
description: Bad Request
"401":
description: Unauthorized
"500":
Expand Down Expand Up @@ -218,6 +226,10 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Flow'
examples:
Request json example:
description: Request json example
externalValue: swagger/agama.json
responses:
"201":
description: Created
Expand Down Expand Up @@ -289,6 +301,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Flow'
"400":
description: Bad Request
"401":
description: Unauthorized
"500":
Expand Down Expand Up @@ -1185,12 +1199,11 @@ paths:
operationId: get-properties-persistence
responses:
"200":
description: Jans Authorization Server config properties
description: Jans Authorization Server persistence type
content:
application/json:
schema:
type: string
description: Jans Auth Server persistence type
$ref: '#/components/schemas/PersistenceConfiguration'
"401":
description: Unauthorized
"500":
Expand Down Expand Up @@ -3129,13 +3142,9 @@ components:
facterData:
$ref: '#/components/schemas/FacterData'
AuthenticationMethod:
required:
- defaultAcr
type: object
properties:
defaultAcr:
maxLength: 2147483647
minLength: 1
type: string
Flow:
type: object
Expand Down Expand Up @@ -3317,18 +3326,18 @@ components:
$ref: '#/components/schemas/AttributeValidation'
tooltip:
type: string
userCanView:
adminCanView:
type: boolean
adminCanEdit:
type: boolean
userCanAccess:
type: boolean
adminCanView:
type: boolean
userCanEdit:
userCanView:
type: boolean
adminCanAccess:
type: boolean
userCanEdit:
type: boolean
whitePagesCanView:
type: boolean
baseDn:
Expand Down Expand Up @@ -3976,6 +3985,10 @@ components:
type: array
items:
type: string
accessTokenSigningAlgValuesSupported:
type: array
items:
type: string
forceSignedRequestObject:
type: boolean
requestObjectSigningAlgValuesSupported:
Expand Down Expand Up @@ -4456,8 +4469,15 @@ components:
type: string
agamaConfiguration:
$ref: '#/components/schemas/EngineConfig'
fapi:
type: boolean
allResponseTypesSupported:
uniqueItems: true
type: array
items:
type: string
enum:
- code
- token
- id_token
enabledFeatureFlags:
uniqueItems: true
type: array
Expand All @@ -4484,15 +4504,8 @@ components:
- METRIC
- STAT
- PAR
allResponseTypesSupported:
uniqueItems: true
type: array
items:
type: string
enum:
- code
- token
- id_token
fapi:
type: boolean
AuthenticationFilter:
required:
- baseDn
Expand Down Expand Up @@ -4632,6 +4645,11 @@ components:
type: object
additionalProperties:
type: string
PersistenceConfiguration:
type: object
properties:
persistenceType:
type: string
SmtpConfiguration:
type: object
properties:
Expand Down Expand Up @@ -4777,13 +4795,13 @@ components:
type: boolean
internal:
type: boolean
locationPath:
type: string
locationType:
type: string
enum:
- ldap
- file
locationPath:
type: string
baseDn:
type: string
ScriptError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.*;

import org.apache.commons.lang.StringUtils;

import jakarta.inject.Inject;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
Expand Down Expand Up @@ -63,18 +66,26 @@ public Response getDefaultAuthenticationMethod() {
@Operation(summary = "Updates default authentication method.", description = "Updates default authentication method.", operationId = "put-acrs", tags = {
"Default Authentication Method" }, security = @SecurityRequirement(name = "oauth2", scopes = {
"https://jans.io/oauth/config/acrs.write" }))
@RequestBody(description = "String representing patch-document.", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = AuthenticationMethod.class)))
@RequestBody(description = "String representing patch-document.", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = AuthenticationMethod.class), examples = @ExampleObject(name = "Request json example", value = "{\"defaultAcr\": \"simple_password_auth\"}")))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = AuthenticationMethod.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@PUT
@ProtectedApi(scopes = { ApiAccessConstants.ACRS_WRITE_ACCESS })
public Response updateDefaultAuthenticationMethod(@Valid AuthenticationMethod authenticationMethod) {
public Response updateDefaultAuthenticationMethod(@NotNull AuthenticationMethod authenticationMethod) {
log.debug("ACRS details to update - authenticationMethod:{}", authenticationMethod);
final GluuConfiguration gluuConfiguration = configurationService.findGluuConfiguration();
gluuConfiguration.setAuthenticationMode(authenticationMethod.getDefaultAcr());
configurationService.merge(gluuConfiguration);

if (authenticationMethod == null || StringUtils.isBlank(authenticationMethod.getDefaultAcr())) {
thorwBadRequestException("Default authentication method should not be null or empty !");
}

if (authenticationMethod != null) {
final GluuConfiguration gluuConfiguration = configurationService.findGluuConfiguration();
gluuConfiguration.setAuthenticationMode(authenticationMethod.getDefaultAcr());
configurationService.merge(gluuConfiguration);
}
return Response.ok(authenticationMethod).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
Expand Down Expand Up @@ -114,7 +115,7 @@ public Response getFlowByName(@PathParam(ApiConstants.QNAME) @NotNull String flo
@Operation(summary = "Create a new agama flow", description = "Create a new agama flow", operationId = "post-agama-flow", tags = {
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
"https://jans.io/oauth/config/agama.write" }))
@RequestBody(description = "Agama Flow", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class)))
@RequestBody(description = "Agama Flow", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Request json example" , value ="{\"source\":\"Flow test\\n\\tBasepath \\\"hello\\\"\\n\\nin = { name: \\\"John\\\" }\\nRRF \\\"index.ftlh\\\" in\\n\\nLog \\\"Done!\\\"\\nFinish \\\"john_doe\\\"\",\"qname\":\"test\"}")))
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
Expand Down Expand Up @@ -148,6 +149,7 @@ public Response createFlow(@Valid Flow flow)
@RequestBody(description = "Agama Flow", content = @Content(mediaType = MediaType.TEXT_PLAIN, schema = @Schema(implementation = String.class)))
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@POST
Expand Down
Loading

0 comments on commit 8113841

Please sign in to comment.