Skip to content

Commit

Permalink
Merge branch 'master' into feature/SHIBUI-701
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Smith committed Nov 9, 2018
2 parents e0fe409 + a7665b8 commit 3fa8e14
Show file tree
Hide file tree
Showing 23 changed files with 173 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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 org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -26,6 +28,8 @@ import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR
@RequestMapping('/api/ui/MetadataSources')
class MetadataSourcesUiDefinitionController {

private static final Logger logger = LoggerFactory.getLogger(MetadataSourcesUiDefinitionController.class);

@Autowired
JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry

Expand All @@ -46,8 +50,8 @@ class MetadataSourcesUiDefinitionController {
jsonSchemaBuilderService.addRelyingPartyOverridesCollectionDefinitionsToJson(parsedJson["definitions"])
return ResponseEntity.ok(parsedJson)
}
catch (Exception e) {
e.printStackTrace()
catch (IOException e) {
logger.error("An error occurred while attempting to get json schema for metadata sources!", e)
return ResponseEntity.status(INTERNAL_SERVER_ERROR)
.body([jsonParseError : e.getMessage(),
sourceUiSchemaDefinitionFile: this.jsonSchemaLocation.url])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package edu.internet2.tier.shibboleth.admin.ui.domain;

import java.util.Collection;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
* @author Bill Smith (wsmith@unicon.net)
*/
@Setter
@Getter
public class RelyingPartyOverrideProperty {
private String name;
private String displayName;
Expand All @@ -18,86 +22,6 @@ public class RelyingPartyOverrideProperty {
private String attributeName;
private String attributeFriendlyName;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDisplayName() {
return displayName;
}

public void setDisplayName(String displayName) {
this.displayName = displayName;
}

public String getDisplayType() {
return displayType;
}

public void setDisplayType(String displayType) {
this.displayType = displayType;
}

public String getDefaultValue() {
return defaultValue;
}

public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}

public String getHelpText() {
return helpText;
}

public void setHelpText(String helpText) {
this.helpText = helpText;
}

public String getPersistType() {
return persistType;
}

public void setPersistType(String persistType) {
this.persistType = persistType;
}

public String getPersistValue() {
return persistValue;
}

public void setPersistValue(String persistValue) {
this.persistValue = persistValue;
}

public List<String> getDefaultValues() {
return defaultValues;
}

public void setDefaultValues(List<String> defaultValues) {
this.defaultValues = defaultValues;
}

public String getAttributeName() {
return attributeName;
}

public void setAttributeName(String attributeName) {
this.attributeName = attributeName;
}

public String getAttributeFriendlyName() {
return attributeFriendlyName;
}

public void setAttributeFriendlyName(String attributeFriendlyName) {
this.attributeFriendlyName = attributeFriendlyName;
}

@Override
public String toString() {
return "RelyingPartyOverrideProperty{"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package edu.internet2.tier.shibboleth.admin.ui.jsonschema
package edu.internet2.tier.shibboleth.admin.ui.jsonschema;

import java.util.List;

/**
* Indicates JSON schema validation failure. Encapsulates a list of error messages produced by JSON schema validator
Expand All @@ -8,9 +10,9 @@
*/
class JsonSchemaValidationFailedException extends RuntimeException {

def errors
List<String> errors;

JsonSchemaValidationFailedException(List<String> errors) {
this.errors = errors
this.errors = errors;
}
}
2 changes: 2 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spring.jpa.properties.hibernate.format_sql=false

spring.jpa.hibernate.use-new-id-generator-mappings=true

# Set the following property to periodically write out the generated metadata files. There is no default value; the following is just an example
# shibui.metadata-dir=/opt/shibboleth-idp/metadata/generated
shibui.logout-url=/dashboard

Expand All @@ -59,5 +60,6 @@ shibui.entity-attributes-filters-ui-schema-location=classpath:entity-attributes-
###
# metadata-providers.xml write configuration

# Set the following property to periodically write out metadata providers configuration. There is no default value; the following is just an example
# shibui.metadataProviders.target=file:/opt/shibboleth-idp/conf/shibui-metadata-providers.xml
# shibui.metadataProviders.taskRunRate=30000
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ label.entity-id=Entity ID
label.service-provider-name=Service Provider Name
label.organization=Organization
label.contacts=Contacts
label.contact=Contact
label.mdui=MDUI Information
label.service-provider-sso-descriptor=Service Provider Sso Descriptor
label.service-enabled=Service Enabled
Expand Down
1 change: 1 addition & 0 deletions backend/src/main/resources/metadata-sources-ui-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
},
"definitions": {
"Contact": {
"title": "label.contact",
"type": "object",
"required": [
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ class MetadataResolverRepositoryTests extends Specification {
it.name = 'original'
it.resourceId = 'new-filter-UUID'
it.attributeRelease = ['attr-for-release']
def overrides = [:]
overrides["signAssertion"] = true
it.setRelyingPartyOverrides(overrides) // to make sure it.rebuildAttributes() is called
it.setRelyingPartyOverrides(['signAssertion': true]) // to make sure it.rebuildAttributes() is called
it
}
MetadataResolver metadataResolver = metadataResolverRepository.findAll().iterator().next()
Expand Down Expand Up @@ -121,8 +119,7 @@ class MetadataResolverRepositoryTests extends Specification {
it.name = 'updated'
it.resourceId = 'new-filter-UUID'
it.attributeRelease = ['attr-for-release', 'attr-for-release2']
it.relyingPartyOverrides = [:]
it.relyingPartyOverrides.put("signAssertion", false)
it.relyingPartyOverrides = ['signAssertion': false]
it
}
metadataResolver = metadataResolverRepository.findAll().iterator().next()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomPropertiesConf
import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor
import edu.internet2.tier.shibboleth.admin.ui.domain.XSAny
import edu.internet2.tier.shibboleth.admin.ui.domain.XSBoolean
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.*
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.AssertionConsumerServiceRepresentation
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.ContactRepresentation
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityDescriptorRepresentation
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.LogoutEndpointRepresentation
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.MduiRepresentation
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.OrganizationRepresentation
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.SecurityInfoRepresentation
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.ServiceProviderSsoDescriptorRepresentation
import edu.internet2.tier.shibboleth.admin.ui.opensaml.OpenSamlObjects
import edu.internet2.tier.shibboleth.admin.ui.util.RandomGenerator
import edu.internet2.tier.shibboleth.admin.ui.util.TestObjectGenerator
Expand Down Expand Up @@ -473,8 +480,7 @@ class JPAEntityDescriptorServiceImplTests extends Specification {

def test = openSamlObjects.marshalToXmlString(service.createDescriptorFromRepresentation(new EntityDescriptorRepresentation().with {
it.entityId = 'http://test.example.org/test1'
it.relyingPartyOverrides = [:]
it.relyingPartyOverrides["forceAuthn"] = true
it.relyingPartyOverrides = ['forceAuthn': true]
it
}))

Expand Down
72 changes: 72 additions & 0 deletions docs/DEFAULTPROPERTIES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Default properties

This is a reflection of the default `application.properties` file included in the distribution. Note that lines
beginning with `#` are commented out.

Please refer to the Spring Boot documentation [https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html]
for more information.

```properties
# Server Configuration
#server.port=8080

# Logging Configuration
#logging.config=classpath:log4j2.xml

logging.level.org.springframework=INFO
logging.level.edu.internet2.tier.shibboleth.admin.ui=INFO

# Database Credentials
spring.datasource.username=shibui
spring.datasource.password=shibui

# Database Configuration H2
spring.datasource.url=jdbc:h2:mem:shibui;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.platform=h2
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true


# Database Configuration PostgreSQL
#spring.datasource.url=jdbc:postgresql://localhost:5432/shibui
#spring.datasource.driverClassName=org.postgresql.Driver
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

#Maria/MySQL DB
#spring.datasource.url=jdbc:mariadb://localhost:3306/shibui
#spring.datasource.driverClassName=org.mariadb.jdbc.Driver
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect

# Liquibase properties
spring.liquibase.enabled=false
#spring.liquibase.change-log=classpath:edu/internet2/tier/shibboleth/admin/ui/database/masterchangelog.xml

# Hibernate properties
# for production never ever use create, create-drop. It's BEST to use validate
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=false

spring.jpa.hibernate.use-new-id-generator-mappings=true

# Set the following property to periodically write out the generated metadata files. There is no default value; the following is just an example
# shibui.metadata-dir=/opt/shibboleth-idp/metadata/generated
shibui.logout-url=/dashboard

# spring.profiles.active=default

#shibui.default-password=

#Actuator endpoints (info)
# Un-comment to get full git details exposed like author, abbreviated SHA-1, commit message
#management.info.git.mode=full

###
# metadata-providers.xml write configuration

# Set the following property to periodically write out metadata providers configuration. There is no default value; the following is just an example
# shibui.metadataProviders.target=file:/opt/shibboleth-idp/conf/shibui-metadata-providers.xml
# shibui.metadataProviders.taskRunRate=30000
```
22 changes: 22 additions & 0 deletions docs/METADATAPROVIDERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Metadata providers

The application can generate a `metadata-providers.xml` configuration appropriate for use in the Shibboleth IdP.
There are 2 ways to access this configuration: through a web endpoint or a file.

1. Web endpoint

A request can be made to the `${ui.baseUrl}/api/MetadataResolvers` to get the
current configuration

2. File export

A file can be periodically written to disk. Set the application property `shibui.metadataProviders.target`,
pointing to a spring file resource. Note that there is no value set by default, and nothing will be written
out by default. A file, once defined, will be written every 30 seconds by default. To change the rate, set the
`shibui.metadataProviders.taskRunRate` application property, in milliseconds.

## Docker considerations

If writing the file out, one should use a mount in the docker container for the destination. While a bind mount
might be easiest, if running on a Windows host, one might run into problems. This is easily avoided by using a
volume instead. Refer to [https://docs.docker.com/storage/] for more information.
21 changes: 21 additions & 0 deletions docs/METADATASOURCES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Metdata Sources

Metadata sources in the UI are individual metadata artifacts describing single entities, typically
relying parties. There are 2 ways to access these artifacts.

1. MDQ

_To be written_

2. File export

Files can be periodically written to disk. Define the application property `shibui.metadata-dir`,
and the files will be written out by default every 30 seconds. Note that there is no default value
set for this property and no file will be written by default. To change the run rate, set the
`shibui.taskRunRate` application property, in milliseconds.

## Docker considerations

If writing the files out, one should use a mount in the docker container for the destination. While a bind mount
might be easiest, if running on a Windows host, one might run into problems. This is easily avoided by using a
volume instead. Refer to [https://docs.docker.com/storage/] for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { UpdateFilterRequest } from '../action/collection.action';
import { CancelCreateFilter, UpdateFilterChanges } from '../action/filter.action';
import { PreviewEntity } from '../../domain/action/entity.action';
import { EntityAttributesFilterEntity } from '../../domain/entity';
import { shareReplay } from 'rxjs/operators';

@Component({
selector: 'edit-filter-page',
Expand Down Expand Up @@ -40,7 +41,7 @@ export class EditFilterComponent {
) {
this.definition = MetadataFilterTypes.EntityAttributesFilter;

this.schema$ = this.schemaService.get(this.definition.schema);
this.schema$ = this.schemaService.get(this.definition.schema).pipe(shareReplay());
this.isSaving$ = this.store.select(fromFilter.getCollectionSaving);
this.model$ = this.store.select(fromFilter.getSelectedFilter);

Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/metadata/filter/container/new-filter.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { Subject, Observable, of } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { takeUntil, shareReplay } from 'rxjs/operators';

import * as fromFilter from '../reducer';
import { MetadataFilterTypes } from '../model';
Expand Down Expand Up @@ -39,7 +39,7 @@ export class NewFilterComponent implements OnDestroy, OnInit {
) {
this.definition = MetadataFilterTypes.EntityAttributesFilter;

this.schema$ = this.schemaService.get(this.definition.schema);
this.schema$ = this.schemaService.get(this.definition.schema).pipe(shareReplay());
this.isSaving$ = this.store.select(fromFilter.getCollectionSaving);
this.model$ = of(<MetadataFilter>{});
}
Expand All @@ -51,6 +51,7 @@ export class NewFilterComponent implements OnDestroy, OnInit {
this.statusChangeEmitted$
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(valid => {
console.log(valid);
this.isValid = valid.value ? valid.value.length === 0 : true;
});

Expand Down
Loading

0 comments on commit 3fa8e14

Please sign in to comment.