2011-02-02 17 views
11

Sembra che la maggior parte delle informazioni WIF disponibili sia utile per abilitare l'autenticazione federata su intere applicazioni. Sono interessato all'utilizzo dell'API per creare richieste di autenticazione SAML e ricevere/interpretare le risposte SAML.Crea richiesta di autenticazione SAML utilizzando WIF

Ho trovato il seguente post su SO Reading SAML Attributes from SAML Token che mi fa andare nella giusta direzione per quanto riguarda la ricezione e l'interpretazione delle risposte SAML. Qualcuno può darmi maggiori informazioni su come potrei usare l'API per creare richieste SAML?

Qualsiasi altra informazione (materiale di lettura, video, ecc.) Sull'API in generale sarebbe molto apprezzata.

risposta

9

Ecco un po 'sotto forma ad esempio una delle our samples che mostra come creare programatically una richiesta per un (SAML) Token di sicurezza per un STS:

private static SecurityToken GetSamlToken(string realm, string stsEndpoint, ClientCredentials clientCredentials) 
    { 
     using (var factory = new WSTrustChannelFactory(
      new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential), 
      new EndpointAddress(new Uri(stsEndpoint)))) 
     { 
      factory.Credentials.UserName.UserName = clientCredentials.UserName.UserName; 
      factory.Credentials.UserName.Password = clientCredentials.UserName.Password; 
      factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 
      factory.TrustVersion = TrustVersion.WSTrust13; 

      WSTrustChannel channel = null; 

      try 
      { 
       var rst = new RequestSecurityToken 
           { 
            RequestType = WSTrust13Constants.RequestTypes.Issue, 
            AppliesTo = new EndpointAddress(realm), 
            KeyType = KeyTypes.Bearer, 
           }; 

       channel = (WSTrustChannel)factory.CreateChannel(); 

       return channel.Issue(rst); 
      } 
      finally 
      { 
       if (channel != null) 
       { 
        channel.Abort(); 
       } 

       factory.Abort(); 
      } 
     } 
+0

Questo è stato di grande aiuto. Grazie, Eugenio. –

+4

Non credo che questo crei un SAML 'AuthnRequest' affatto. Sembra creare un WSTrust 'RequestSecurityToken'. – atoumey