KNF:Scoping: verschil tussen versies

Uit Kennisnet Developers Documentatie
Naar navigatie springen Naar zoeken springen
Regel 5: Regel 5:
   
 
https://simplesamlphp.org/docs/stable/simplesamlphp-scoping
 
https://simplesamlphp.org/docs/stable/simplesamlphp-scoping
  +
  +
==Toevoegen van scoping aan componentspace AuthnRequest()==
  +
  +
<syntaxhighlight lang="java">
  +
  +
' Create the AuthnRequest
  +
Private Function CreateAuthnRequest(certificate As X509Certificate2, ssoURL As String, UseScoping as Boolean, Brin as String) As XmlElement
  +
  +
' Define EntityID
  +
Dim entityId As String = ConfigurationManager.AppSettings("Entree.EntityID")
  +
Dim authnRequest As New AuthnRequest()
  +
authnRequest.Destination = ssoURL
  +
authnRequest.Issuer = New Issuer(entityId)
  +
authnRequest.ForceAuthn = False
  +
authnRequest.NameIDPolicy = New NameIDPolicy(Nothing, Nothing, True)
  +
  +
'Gebruik scoping om school selectie scherm over te slaan?
  +
If UseScoping = True Then
  +
  +
'download json van kennisnet waar de ProviderIDs in zitten
  +
Dim wc As New WebClient()
  +
Dim json As String = wc.DownloadString(“https://aselect.entree.kennisnet.nl/openaselect/sso/wayfsearch2?type=getAll&spCode=” & entityId)
  +
Dim wayfsearch As JArray = JArray.Parse(json)
  +
Dim ProviderID As String = ""
  +
For Each w In wayfsearch.Children
  +
'zoek voor het juiste providerID bij de opgegeven BRIN
  +
If w("ko")("brin").ToString().ToLower() = Brin.ToLower() Then
  +
ProviderID = w("idp")("asorgcode").ToString()
  +
End If
  +
Next
  +
  +
If String.IsNullOrEmpty(ProviderID) = False Then 'ProviderID gevonden
  +
Dim ips As IDPList = New IDPList()
  +
Dim ipe As IDPEntry = New IDPEntry()
  +
ipe.ProviderID = ProviderID
  +
ips.IDPEntries.Add(ipe)
  +
Dim scopeing As Scoping = New Scoping()
  +
scopeing.IDPList = ips
  +
scopeing.ProxyCount = 2
  +
authnRequest.Scoping = scopeing
  +
End If
  +
End If
  +
authnRequest.ProtocolBinding = SAMLIdentifiers.BindingURIs.HTTPPost
  +
authnRequest.AssertionConsumerServiceURL = ConfigurationManager.AppSettings("AssertionConsumerServiceURL")
  +
  +
Dim authnRequestXml As XmlElement = authnRequest.ToXml()
  +
' Add signature
  +
SAMLMessageSignature.Generate(authnRequestXml, certificate.PrivateKey, certificate)
  +
Return authnRequestXml
  +
End Function
  +
</syntaxhighlight>
  +
   
 
[[Categorie:Kennisnet Federatie]]
 
[[Categorie:Kennisnet Federatie]]

Versie van 25 apr 2017 12:41

Met een SAML koppeling is dit mogelijk met de functie scoping.

Meer informatie daarover kan je op deze website vinden:

https://simplesamlphp.org/docs/stable/simplesamlphp-scoping

Toevoegen van scoping aan componentspace AuthnRequest()

    ' Create the AuthnRequest
    Private Function CreateAuthnRequest(certificate As X509Certificate2, ssoURL As String, UseScoping as Boolean, Brin as String) As XmlElement

        ' Define EntityID
        Dim entityId As String = ConfigurationManager.AppSettings("Entree.EntityID")
        Dim authnRequest As New AuthnRequest()
        authnRequest.Destination = ssoURL
        authnRequest.Issuer = New Issuer(entityId)
        authnRequest.ForceAuthn = False
        authnRequest.NameIDPolicy = New NameIDPolicy(Nothing, Nothing, True)

        'Gebruik scoping om school selectie scherm over te slaan?
        If UseScoping = True Then

            'download json van kennisnet waar de ProviderIDs in zitten
            Dim wc As New WebClient()
            Dim json As String = wc.DownloadString(https://aselect.entree.kennisnet.nl/openaselect/sso/wayfsearch2?type=getAll&spCode=” & entityId)
            Dim wayfsearch As JArray = JArray.Parse(json)
            Dim ProviderID As String = ""
            For Each w In wayfsearch.Children
                'zoek voor het juiste providerID bij de opgegeven BRIN
                If w("ko")("brin").ToString().ToLower() = Brin.ToLower() Then
                    ProviderID = w("idp")("asorgcode").ToString()
                End If
            Next

            If String.IsNullOrEmpty(ProviderID) = False Then 'ProviderID gevonden
                Dim ips As IDPList = New IDPList()
                Dim ipe As IDPEntry = New IDPEntry()
                ipe.ProviderID = ProviderID
                ips.IDPEntries.Add(ipe)
                Dim scopeing As Scoping = New Scoping()
                scopeing.IDPList = ips
                scopeing.ProxyCount = 2
                authnRequest.Scoping = scopeing
            End If
        End If
        authnRequest.ProtocolBinding = SAMLIdentifiers.BindingURIs.HTTPPost
            authnRequest.AssertionConsumerServiceURL = ConfigurationManager.AppSettings("AssertionConsumerServiceURL")

        Dim authnRequestXml As XmlElement = authnRequest.ToXml()
        ' Add signature
        SAMLMessageSignature.Generate(authnRequestXml, certificate.PrivateKey, certificate)
        Return authnRequestXml
    End Function