Last-modified: 2017-06-05 (月) 17:46:22
SimpleSAMLphp/検証目的のIdP構築

概要

検証目的のIdPとして、SimpleSAMLphpを構築します。
仮想マシンよりも手軽なので今回はAzure App Serviceにデプロイします。
セキュリティに関わる事項は、この記事の範疇外です。
Azure App Serviceへの手軽なデプロイ方法として、ローカルgit, ftpsがありますが、gitの恩恵に預かりたいのでgitで進めます。
ただしSimpleSAMLphpのリポジトリからのインストールは、環境整備の手間がかかるので、パッケージされたデータをソースとして使います。

手順(Azure)

  1. 新規App Service作成(Freeプランで可能)
  2. [デプロイオプション]で[ローカルGitリポジトリ]を選択
  3. [デプロイ資格情報]設定(リソース間で共通なので、今まで設定したことがあれば不要)
  4. [アプリケーション設定]仮想アプリケーションとディレクトリ
    仮想ディレクトリ物理パスアプリケーション?
    /site\wwwroot\wwwアプリケーション
    /simplesamlsite\wwwroot\wwwアプリケーション
  5. [概要]で[Git クローン URL]を控える

手順(SimpleSAMLphp)

  1. ソース取得
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
    
     
     
     
     
    
    wget https://github.com/simplesamlphp/simplesamlphp/releases/download/v1.14.14/simplesamlphp-1.14.14.tar.gz
    tar zxf simplesamlphp-1.14.14.tar.gz
    mv simplesamlphp-1.14.14 idp 
    cd idp
  2. gitリポジトリ作成
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
    
     
     
     
     
    
    git init
    git add .
    git commit -a -m "init"
    git remote add azure <上で控えた[Git クローン URL]>
  3. ソルトの生成
    Everything is expanded.Everything is shortened.
      1
    
     
    
    tr -c -d '0123456789abcdefghijklmnopqrstuvwxyz' </dev/urandom | dd bs=32 count=1 2>/dev/null;echo
  4. vi config/config.php
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
    
    -
    !
     
     
    
    # 変更(既存の設定を置き換えるか、末尾に挿入しないとデフォルト値で上書きされてしまうので注意)
    'enable.saml20-idp' => true,
    'auth.adminpassword' => '<adminパスワード>',
    'secretsalt' => '<上記で生成したソルト値>'
  5. サンプル用認証機能の有効化
    Everything is expanded.Everything is shortened.
      1
    
     
    
    touch modules/exampleauth/enable
  6. vi config/authsources.php
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
    
    -
    |
    |
    !
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
    # コメント解除
    # メールアドレス追加
    # '<ユーザー名>:<パスワード>'
    'example-userpass' => array(
            'exampleauth:UserPass',
     
            // Give the user an option to save their username for future login attempts
            // And when enabled, what should the default be, to save the username or not
            //'remember.username.enabled' => FALSE,
            //'remember.username.checked' => FALSE,
     
            'student:studentpass' => array(
                'uid' => array('test'),
                'eduPersonAffiliation' => array('member', 'student'),
                'mail' => array('[email protected]'),
            ),
            'employee:employeepass' => array(
                'uid' => array('employee'),
                'eduPersonAffiliation' => array('member', 'employee'),
                'mail' => array('[email protected]'),
            ),
        ),
  7. 署名,暗号化用自己証明書作成
    Everything is expanded.Everything is shortened.
      1
    
     
    
    openssl req -newkey rsa:2048 -new -x509 -days 3652 -nodes -subj "/C=JP/ST=Tokyo/CN=idp" -out cert/idp.crt -keyout cert/idp.key
  8. vi metadata/saml20-idp-hosted.php
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
    
    -
    !
     
     
    -
    !
     
     
     
     
     
     
    
    # 変更
    'privatekey' => 'idp.key',
    'certificate' => 'idp.crt',
     
    # コメント解除
    'signature.algorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
    'attributes.NameFormat' => 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri',
        'authproc' => array(
            // Convert LDAP names to oids.
            100 => array('class' => 'core:AttributeMap', 'name2oid'),
        ),
    
  9. デプロイ
    Everything is expanded.Everything is shortened.
      1
      2
      3
    
     
     
     
    
    git add .
    git commit -a -m "Test IdP setting"
    git push azure master

確認

  1. デプロイ左記のURIをブラウザで開く
  2. [Federation]ページから、IdPのメタデータが見えること
    01.png
  3. [Autentication]ページから、ソース[example-userpass]で、ログインできることなどを確認する
    02.png

検証時の環境

参考