2016-05-17 13 views
0

実際、WSO2 Identity Server(WSO2ISログインページにリダイレクト)を使用してSimpleSAMLで認証するCakePHPアプリケーションがあります。自分のアプリケーションにページを作成し、その情報をWSO2ISに送信してユーザーを認証する必要があります。どうしたらいいですか?私はそれについてのサンプル/ドキュメントを見つけられませんでした。 私はこれに続いてtutorialです。 simplesamlでWOS2 Identity ServerとPHP認証の統合

ファイル: のconfig/authsources.php

<?php 
$config = array(
    'wso2-sp' => array(
     'saml:SP', 
     'entityID' => 'IntranetSP', // I supposed that it is the ID of my Service Provider 
     'idp' => 'https://soa.rw1.local:9443/samlsso' 
    ) 
); 

?> 

メタデータ/ saml20-IDP-remote.php私WSO2で

<?php 

$metadata['https://soa.rw1.local:9443/samlsso'] = array(

    'name' => array(

     'en' => 'WSO2 IS', 

     'no' => 'WSO2 IS', 

    ), 

    'description' => 'Login with WSO2 IS SAML2 IdP.', 

    'SingleSignOnService' => 'https://soa.rw1.local:9443/samlsso', 

    'SingleLogoutService' => 'https://soa.rw1.local:9443/samlsso', 

    'certFingerprint'  => '6bf8e136eb36d4a56ea05c7ae4b9a45b63bf975d' 



); 

?> 

は次のとおりです。

Service provider Configuration: 

Service Provider Name: IntranetSP 
Local & Outbound Authentication Configuration/Request Path Authentication Configuration: basic-auth 
+0

シンプルなサンプルphp [1]を使用して、セットアップのために[1]を実行することができます。https://docs.wso2.com/display/IS500/SAML2+IdP+with+SimpleSAMLphp+Service+Provider –

+0

あなたが他のカスタム認証者を参照することができるように同じ作業を行う認証者[1] https://docs.wso2.com/display/ISCONNECTORS/Identity+Server+Authenticators+and+Connectors –

+0

@IsuraDilharaKarunaratneはい、私はこの例を使用しました私の問題は、PHPログインページを作成して(簡単です)、WSO2に認証情報を送る必要があるということです。実際、ログインページはWSO2にありますので、PHPアプリケーションがユーザーを完全な認証を行うWSO2ログインページ。 –

答えて

0

でサービスプロバイダの設定は、ローカルおよびアウトバウンドの認証設定で、SPをuに設定しますこの要求については、thisを参照してください。

以下は、クライアントから要求を送信できるJavaコードです。

@Test(alwaysRun = true, description = "Test login success") 
public void testLoginSuccess() throws Exception { 
    HttpPost request = new HttpPost(TRAVELOCITY_SAMPLE_APP_URL + "/samlsso?SAML2.HTTPBinding=HTTP-POST"); 
    List<NameValuePair> urlParameters = new ArrayList<>(); 
    urlParameters.add(new BasicNameValuePair("username", adminUsername)); 
    urlParameters.add(new BasicNameValuePair("password", adminPassword)); 
    request.setEntity(new UrlEncodedFormEntity(urlParameters)); 
    HttpResponse response = client.execute(request); 
    BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); 
    String line; 
    String samlRequest = ""; 
    String secToken = ""; 

    while ((line = rd.readLine()) != null) { 
     if (line.contains("name='SAMLRequest'")) { 
      String[] tokens = line.split("'"); 
      samlRequest = tokens[5]; 
     } 
     if (line.contains("name='sectoken'")) { 
      String[] tokens = line.split("'"); 
      secToken = tokens[5]; 
     } 
    } 
    EntityUtils.consume(response.getEntity()); 
    request = new HttpPost(isURL + "samlsso"); 
    urlParameters = new ArrayList<>(); 
    urlParameters.add(new BasicNameValuePair("sectoken", secToken)); 
    urlParameters.add(new BasicNameValuePair("SAMLRequest", samlRequest)); 
    request.setEntity(new UrlEncodedFormEntity(urlParameters)); 
    response = client.execute(request); 
    String samlResponse = ""; 
    rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); 
    while ((line = rd.readLine()) != null) { 
     if (line.contains("name='SAMLResponse'")) { 
      String[] tokens = line.split("'"); 
      samlResponse = tokens[5]; 
     } 
    } 
    Base64 base64Decoder = new Base64(); 
    samlResponse = new String(base64Decoder.decode(samlResponse)) 
    EntityUtils.consume(response.getEntity()); 
} 

これは、PHPで同じ要求を送信することで実現できます。

ただし、ログインページを変更する必要がある場合は、自分のページを使用せずにhereのようにwso2 ISログインページをカスタマイズできます。あなたの要件がこれなら、あなたの人生をはるかに容易にするので、これを行うことをお勧めします。

+0

しかし、これを私のPHPアプリケーションにどのように適用できますか?私はすでに設定済みのSPを使用しています(私はWSO2IS 5.0.0を使用しています) –

+0

SPを更新することはできません.SPで要求パス認証を有効にする必要があります。そうしないと、ユーザーはIS ssoログインページ。 –

+0

私はリンクを読みましたが、PHPでsimplesamlを設定する方法についての説明はなく、ISでの設定方法のみです。私はISのサービスプロバイダをチュートリアルのように追加しました(Request Path Auth Conf - Local&Out ...の基本認証を追加しました)。しかし今、私はどのようにsimplesamlを設定できるのか分かりません。私は自分の質問を編集し、私のconfファイルを入れます –

関連する問題