-
-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #602 from johnnyshields/refactor-metadata-class
Refactor the OneLogin::RubySaml::Metadata class
- Loading branch information
Showing
4 changed files
with
133 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -764,3 +764,27 @@ end | |
``` | ||
The `attribute_value` option additionally accepts an array of possible values. | ||
## Custom Metadata Fields | ||
Some IdPs may require to add SPs to add additional fields (Organization, ContactPerson, etc.) | ||
into the SP metadata. This can be acheived by extending the `OneLogin::RubySaml::Metadata` | ||
class and overriding the `#add_extras` method as per the following example: | ||
```ruby | ||
class MyMetadata < OneLogin::RubySaml::Metadata | ||
def add_extras(root, _settings) | ||
org = root.add_element("md:Organization") | ||
org.add_element("md:OrganizationName", 'xml:lang' => "en-US").text = 'ACME Inc.' | ||
org.add_element("md:OrganizationDisplayName", 'xml:lang' => "en-US").text = 'ACME' | ||
org.add_element("md:OrganizationURL", 'xml:lang' => "en-US").text = 'https://www.acme.com' | ||
cp = root.add_element("md:ContactPerson", 'contactType' => 'technical') | ||
cp.add_element("md:GivenName").text = 'ACME SAML Team' | ||
cp.add_element("md:EmailAddress").text = '[email protected]' | ||
end | ||
end | ||
# Output XML with custom metadata | ||
MyMetadata.new.generate(settings) | ||
``` |
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