-
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.
Merge branch 'master' into SHIBUI-922
- Loading branch information
Showing
99 changed files
with
5,671 additions
and
339 deletions.
There are no files selected for viewing
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
60 changes: 60 additions & 0 deletions
60
...rnet2/tier/shibboleth/admin/ui/controller/NameIdFormatFilterUiDefinitionController.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,60 @@ | ||
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 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.nameIdFormatFilterSchema | ||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR | ||
|
||
/** | ||
* Controller implementing REST resource responsible for exposing structure definition for nameid format filter user | ||
* interface in terms of JSON schema. | ||
* | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@RestController | ||
@RequestMapping('/api/ui/NameIdFormatFilter') | ||
@Slf4j | ||
class NameIdFormatFilterUiDefinitionController { | ||
|
||
@Autowired | ||
JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry | ||
|
||
JsonSchemaResourceLocation jsonSchemaLocation | ||
|
||
@Autowired | ||
ObjectMapper jacksonObjectMapper | ||
|
||
@Autowired | ||
JsonSchemaBuilderService jsonSchemaBuilderService | ||
|
||
@GetMapping | ||
ResponseEntity<?> getUiDefinitionJsonSchema() { | ||
try { | ||
def parsedJson = jacksonObjectMapper.readValue(this.jsonSchemaLocation.url, Map) | ||
jsonSchemaBuilderService.addRelyingPartyOverridesCollectionDefinitionsToJson(parsedJson["definitions"]) | ||
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 = nameIdFormatFilterSchema(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
48 changes: 48 additions & 0 deletions
48
backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/service/UserBootstrap.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,48 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.service | ||
|
||
import com.opencsv.CSVReader | ||
import edu.internet2.tier.shibboleth.admin.ui.configuration.ShibUIConfiguration | ||
import edu.internet2.tier.shibboleth.admin.ui.security.model.Role | ||
import edu.internet2.tier.shibboleth.admin.ui.security.model.User | ||
import edu.internet2.tier.shibboleth.admin.ui.security.repository.RoleRepository | ||
import edu.internet2.tier.shibboleth.admin.ui.security.repository.UserRepository | ||
import groovy.util.logging.Slf4j | ||
import org.springframework.boot.context.event.ApplicationStartedEvent | ||
import org.springframework.context.event.EventListener | ||
import org.springframework.stereotype.Component | ||
|
||
import javax.transaction.Transactional | ||
|
||
@Component | ||
@Slf4j | ||
class UserBootstrap { | ||
private final ShibUIConfiguration shibUIConfiguration | ||
private final UserRepository userRepository | ||
private final RoleRepository roleRepository | ||
|
||
UserBootstrap(ShibUIConfiguration shibUIConfiguration, UserRepository userRepository, RoleRepository roleRepository) { | ||
this.shibUIConfiguration = shibUIConfiguration | ||
this.userRepository = userRepository | ||
this.roleRepository = roleRepository | ||
} | ||
|
||
@Transactional | ||
@EventListener | ||
void bootstrapUsersAndRoles(ApplicationStartedEvent e) { | ||
if (shibUIConfiguration.userBootstrapResource) { | ||
log.info("configuring users from ${shibUIConfiguration.userBootstrapResource.URI}") | ||
new CSVReader(new InputStreamReader(shibUIConfiguration.userBootstrapResource.inputStream)).each { it -> | ||
def (username, password, firstName, lastName, roleName) = it | ||
def role = roleRepository.findByName(roleName).orElse(roleRepository.save(new Role(name: roleName))) | ||
def user = userRepository.findByUsername(username).orElse(new User(username: username)).with { | ||
it.password = password | ||
it.firstName = firstName | ||
it.lastName = lastName | ||
it.roles.add(role) | ||
it | ||
} | ||
userRepository.save(user) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.