-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api/ui/DynamicRegistration endpoint to deliver json schema for the frontend
- Loading branch information
Showing
5 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...net2/tier/shibboleth/admin/ui/controller/DynamicRegistrationUiDefinitionController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.controller | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper | ||
| import edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation | ||
| import edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocationRegistry | ||
| import edu.internet2.tier.shibboleth.admin.ui.service.JsonSchemaBuilderService | ||
| import groovy.util.logging.Slf4j | ||
| import io.swagger.v3.oas.annotations.tags.Tag | ||
| import io.swagger.v3.oas.annotations.tags.Tags | ||
| import org.springframework.beans.factory.annotation.Autowired | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
|
|
||
| import javax.annotation.PostConstruct | ||
|
|
||
| import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.algorithmFilterSchema | ||
| import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.dynamicRegistrationSchema | ||
| import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR | ||
|
|
||
| /** | ||
| * Controller implementing REST resource responsible for exposing structure definition for dynamic registration user | ||
| * interface in terms of JSON schema. | ||
| */ | ||
| @RestController | ||
| @RequestMapping('/api/ui/DynamicRegistration') | ||
| @Slf4j | ||
| @Tags(value = [@Tag(name = "ui")]) | ||
| class DynamicRegistrationUiDefinitionController { | ||
|
|
||
| @Autowired | ||
| JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry | ||
|
|
||
| JsonSchemaResourceLocation jsonSchemaLocation | ||
|
|
||
| @Autowired | ||
| ObjectMapper jacksonObjectMapper | ||
|
|
||
| @Autowired | ||
| JsonSchemaBuilderService jsonSchemaBuilderService | ||
|
|
||
| @GetMapping | ||
| ResponseEntity<?> getUiDefinitionJsonSchema() { | ||
| try { | ||
| def parsedJson = jacksonObjectMapper.readValue(this.jsonSchemaLocation.url, Map) | ||
| return ResponseEntity.ok(parsedJson) | ||
| } catch (Exception e) { | ||
| log.error(e.getMessage(), e) | ||
| return ResponseEntity.status(INTERNAL_SERVER_ERROR).body([jsonParseError : e.getMessage(), sourceUiSchemaDefinitionFile: this.jsonSchemaLocation.url]) | ||
| } | ||
| } | ||
|
|
||
| @PostConstruct | ||
| void init() { | ||
| this.jsonSchemaLocation = dynamicRegistrationSchema(this.jsonSchemaResourceLocationRegistry) | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
backend/src/main/resources/dynamic-registration.schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| { | ||
| "type": "object", | ||
| "required": [ | ||
| "redirectUris" | ||
| ], | ||
| "properties": { | ||
| "applicationType": { | ||
| "title": "label.application-type", | ||
| "description": "tooltip.application-type", | ||
| "type": "string" | ||
| }, | ||
| "approved": { | ||
| "title": "label.approved", | ||
| "description": "tooltip.approved", | ||
| "type": "boolean" | ||
| }, | ||
| "contacts": { | ||
| "title": "label.contacts", | ||
| "description": "tooltip.contacts", | ||
| "type": "string" | ||
| }, | ||
| "enabled": { | ||
| "title": "label.enabled", | ||
| "description": "tooltip.enabled", | ||
| "type": "boolean" | ||
| }, | ||
| "grantType": { | ||
| "title": "label.grant-type", | ||
| "description": "tooltip.grant-type", | ||
| "type": "string", | ||
| "widget": "select", | ||
| "minLength": 1, | ||
| "oneOf": [ | ||
| { | ||
| "enum": ["authorization_code"], | ||
| "description": "value.authorization-code" | ||
| }, | ||
| { | ||
| "enum": ["implicit"], | ||
| "description": "value.implicit" | ||
| }, | ||
| { | ||
| "enum": ["refresh_token"], | ||
| "description": "value.refresh-token" | ||
| } | ||
| ] | ||
| }, | ||
| "jwks": { | ||
| "title": "label.jwks", | ||
| "description": "tooltip.jwks", | ||
| "type": "string" | ||
| }, | ||
| "logoUri": { | ||
| "title": "label.logo-uri", | ||
| "description": "tooltip.logo-uri", | ||
| "type": "string" | ||
| }, | ||
| "policyUri": { | ||
| "title": "label.policy-uri", | ||
| "description": "tooltip.policy-uri", | ||
| "type": "string" | ||
| }, | ||
| "redirectUris": { | ||
| "title": "label.redirect-uris", | ||
| "description": "tooltip.redirect-uris", | ||
| "type": "string", | ||
| "minLength": 1, | ||
| "maxLength": 255 | ||
| }, | ||
| "responseTypes": { | ||
| "title": "label.response-types", | ||
| "description": "tooltip.response-types", | ||
| "type": "string" | ||
| }, | ||
| "scope": { | ||
| "title": "label.scope", | ||
| "description": "tooltip.scope", | ||
| "type": "string" | ||
| }, | ||
| "subjectType": { | ||
| "title": "label.subject-type", | ||
| "description": "tooltip.subject-type", | ||
| "type": "string" | ||
| }, | ||
| "tokenEndpointAuthMethod": { | ||
| "title": "label.token-endpoint-auth-method", | ||
| "description": "tooltip.token-endpoint-auth-method", | ||
| "type": "string" | ||
| }, | ||
| "tosUri": { | ||
| "title": "label.tos-uri", | ||
| "description": "tooltip.tos-uri", | ||
| "type": "string" | ||
| } | ||
| } | ||
| } |