SimpleSAMLphp で開発用の SAML ID Provider を立てる
SAML によるシングルサインオンに対応したアプリを作るときに、開発環境としてお手軽に試せる ID Provider があると便利なので、SimpleSAMLphp でタダで作る。
OneLogin のアカウントを持っている場合は、 "SAML Test Connector (IdP)" を使えば簡単に作れる。
確認環境
- CentOS 6.5
- PHP 5.3.3
- SimpleSAMLphp 1.13.2
- onelogin/java-saml 1.1.2
インストール
simpleSAMLphp Installation and Configuration を参考にインストールする。
ダウンロードした SimpleSAMLphp のアーカイブを /var/simplesamlphp に展開し、Apache の設定で
Alias /simplesaml /var/simplesamlphp/www
PHP などが正しくインストールされていれば http://hostname/simplesaml/ で以下の様な画面が見える。
設定
admin ユーザのログインパスワード
// config/config.php
'auth.adminpassword' => 'test',
Web 画面でログインできるか確認する。
saml20-idp モジュールを有効化
// config/config.php
'enable.saml20-idp' => true,
Web 画面の設定タブの "SAML 2.0 IdP" が有効化されているか確認する。
認証方法を設定する(exampleauth)
### 有効化 $ touch modules/exampleauth/enable
ID = suer
、パスワード = test
でログインできるようにしておく。
// config/authsources.php <?php $config = array( 'example-userpass' => array( 'exampleauth:UserPass', 'suer:test' => array( 'uid' => array('suer'), 'eduPersonAffiliation' => array('member', 'employee'), ), ),
自己証明書を作成
$ mkdir -p cert $ cd cert $ openssl req -newkey rsa:2048 -new -x509 -days 3652 -nodes -out server.crt -keyout server.pem
設定は
// metadata/saml20-idp-hosted.php 'privatekey' => 'server.pem', 'certificate' => 'server.crt',
Service Provider の準備
ここでは確認のため、 GitHub - onelogin/java-saml: Java SAML toolkit の Sample アプリを使う。
$ git clone https://github.com/onelogin/java-saml.git $ cd java-saml $ mvn package -Dmaven.test.skip=true $ cd sample $ mvn jetty:run
Service Provider の登録
// metadata/saml20-sp-remote.php $metadata['http://localhost:8080/index.jsp'] = array( 'AssertionConsumerService' => 'http://localhost:8080/consume.jsp', 'SingleLogoutService' => '', 'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress', 'simplesaml.nameidattribute' => 'uid', 'simplesaml.attributes' => FALSE, );
http://localhost:8080/index.jsp や http://localhost:8080/consume.jsp は java-saml のサンプルアプリのアドレス。
Service Provider に登録する情報
Web ページの "連携" タブ > SAML 2.0 IdP メタデータの表示から確認
- ID Provider の URL: md:SingleSignOnService#Location の値(http://xxxxxx/xxxxxx/saml2/idp/SSOService.php)
- 証明書: ds:X509Certificate の値 をコピーするか、同ページからダウンロードすることもできる
java-saml のサンプルアプリに ID Provider を設定する
修正するのは以下の2箇所。
// src/main/webapp/index.jsp accSettings.setIdpSsoTargetUrl("ID Provider の URL");
// src/main/webapp/consume.jsp String certificateS = "証明書の内容";
確認
$ mvn jetty:run
ブラウザで http://localhost:8080/ にアクセスして、 SimpleSAMLphp 経由でシングルサインオンできれば成功。
一度目はログイン画面が表示される。
ログインに成功した場合もしくは既にログイン済みの場合、consume.jsp 転送されて ID が表示される。
Atom の Markdown Preview の中国語フォントを日本語フォントにする
環境
Atom 1.1.0
GitHub.com のスタイルに変更
- Packages > Settings View > Open (もしくは ctrl+ ,)
- packages タブから markdown-preview を検索して Settings ボタンをクリック
- Use GitHub.com style をチェック
プレビューのフォントを変更
- Packages > Settings View > Open (もしくは ctrl+ ,)
- Themes タブを開き your stylesheet をクリック
- style.less が開くので末尾に以下を追加
.markdown-preview, .markdown-preview[data-use-github-style] { font-family: "Hiragino Kaku Gothic ProN", Meiryo, sans-serif; }
CentOS 5 32bit で fluent-agent-hydra を無理やり動かす
環境
問題
Go は CentOS 5 をサポートしていないせいか、 CentOS 5 32bit (Linux kernel 2.6.18) 上で fujiwara/fluent-agent-hydra · GitHub の32bit バイナリを動かすと以下のエラーを吐いて死ぬ。
# /usr/local/bin/fluent-agent-hydra -c /etc/fluent-agent-hydra.toml 2015/06/24 15:14:47 [info] Loading config file: /etc/fluent-agent-hydra.toml 2015/06/24 15:14:47 [info] set ReadBufferSize 1048576 2015/06/24 15:14:47 [info] Server localhost:24224 connected 2015/06/24 15:14:47 [info] ServerRoundRobin enabled 2015/06/24 15:14:47 [error] Couldn't create file watcher function not implemented 2015/06/24 15:14:47 [error] function not implemented 2015/06/24 15:14:47 [info] watching events of directory /var/log/httpd panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x1 pc=0x80b3f01] goroutine 1 [running]: github.com/fujiwara/fluent-agent-hydra/hydra.(*Watcher).WatchFile(0x0, 0x1894a690, 0x1e, 0x1e, 0x0, 0x0) /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/hydra/in_tail.go:71 +0x151 github.com/fujiwara/fluent-agent-hydra/hydra.NewInTail(0x18944b40, 0x0, 0x18944c40, 0x18944c80, 0x18944c80, 0x0, 0x0) /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/hydra/in_tail.go:105 +0x94 main.run(0x18944880) /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/cmd/fluent-agent-hydra/main.go:127 +0x525 main.main() /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/cmd/fluent-agent-hydra/main.go:69 +0x869 goroutine 6 [syscall]: os/signal.loop() /usr/local/Cellar/go/1.4.2/libexec/src/os/signal/signal_unix.go:21 +0x21 created by os/signal.init·1 /usr/local/Cellar/go/1.4.2/libexec/src/os/signal/signal_unix.go:27 +0x34 goroutine 7 [chan receive]: github.com/fujiwara/fluent-agent-hydra/hydra.(*Stats).Run(0x189a0580, 0x18944c80) /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/hydra/monitor.go:115 +0x48 created by github.com/fujiwara/fluent-agent-hydra/hydra.NewMonitor /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/hydra/monitor.go:134 +0x17b goroutine 14 [runnable]: github.com/fujiwara/fluent-agent-hydra/hydra.(*OutForward).Run(0x189a1360) /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/hydra/out_forward.go:44 created by main.run /Users/fujiwara/src/github.com/fujiwara/fluent-agent-hydra/cmd/fluent-agent-hydra/main.go:117 +0x96d goroutine 13 [sleep]: net.func·019() /usr/local/Cellar/go/1.4.2/libexec/src/net/dnsclient_unix.go:240 +0x54 created by net.loadConfig /usr/local/Cellar/go/1.4.2/libexec/src/net/dnsclient_unix.go:269 +0x1aa
問題の箇所
[error] Couldn't create file watcher function not implemented というエラーメッセージを頼りに追っていくと fsnotify が以下の箇所で syscall.Pipe2 を呼んでいるところでエラーが発生していることを突き止めた。
修正
- (注意1) Go の流儀をよく理解しないまま対応しているので、もっと良い方法があるかもしれない。
- (注意2) NONBLOCK でなくなっているので性能が落ちる可能性がある
$GOPATH/src/gopkg.in/fsnotify.v1/inotify_poller.go
diff --git a/inotify_poller.go b/inotify_poller.go index 3b41784..9f2b172 100644 --- a/inotify_poller.go +++ b/inotify_poller.go @@ -44,7 +44,7 @@ func newFdPoller(fd int) (*fdPoller, error) { return nil, errno } // Create pipe; pipe[0] is the read end, pipe[1] the write end. - errno = syscall.Pipe2(poller.pipe[:], syscall.O_NONBLOCK) + errno = syscall.Pipe(poller.pipe[:]) if errno != nil { return nil, errno }
まとめ
さっさと CentOS 6 以上に上げよう。
Mac OS X Yosemite で Font Awesome の PNG ファイルを作る
環境
参考
encharm/Font-Awesome-SVG-PNG · GitHub
手順
必要なパッケージのインストール
$ brew install node npm librsvg
librsvg の link がうまくいかなかった旨のメッセージが出た場合は以下も実行する。
$ brew link librsvg
encharm/Font-Awesome-SVG-PNG · GitHub の README には Darwin Port でのやり方が書いてある。
Font-Awesome-SVG-PNG のインストール
$ npm install -g font-awesome-svg-png
PNG ファイルの作成
以下は赤い 40px と 80px の PNG ファイルが欲しい場合。
$ mkdir font-awesome-png $ cd font-awesome-png $ font-awesome-svg-png --color red --sizes 40,80 --no-svg
red ディレクトリ以下に画像が生成される。
Ivy で SNAPSHOT リポジトリの最新版を取得する方法
Ivy はデフォルトだと同じ名前の jar ファイルはローカルにキャッシュしたものを優先するので、SNAPSHOT リポジトリと相性が悪い。
ivysetting.xml で checkmodified を指定して、毎回確認するように変更する。
<ivysettings> <property name="ivy.checksums" value=""/> <settings defaultResolver="chained"/> <resolvers> <chain name="chained" returnFirst="true" changingPattern=".*SNAPSHOT"> <ibiblio name="central" m2compatible="true"/> <ibiblio name="mymavenrepo" m2compatible="true" root="https://example.com/maven2/" checkmodified="true" changingPattern=".*SNAPSHOT" /> </chain> </resolvers> </ivysettings>
Archive するたびに Splunk Mint (旧 Bugsense) に自動で dSYM ファイルをアップロードする
追記: この記事は古い情報です。現在この記事の方法ではアップロードできません。
最新の SplunkMint-iOS をインストールし、以下の記事に従って設定してください。(ただし、アーカイブ時ではなくビルド時にアプロードされます)
Configure your project for symbolication - Splunk Documentation
API キーとトークンの取得
API キーとトークンは Splunk Mint のサイトにログインして、それぞれ以下のページから取得する。
Xcode プロジェクトの設定
Xcode のスキーマ(Xcode 上バーのデバッグ停止ボタンの右) をクリックして Edit Scheme... を選択する。
Archive の Post-actions を開き、+ をクリックして New Run Script Action を選択する。
API_KEY="API キー" API_TOKEN="API トークン" APP_NAME=アプリ名 rm -f $APP_NAME.app.dSYM.zip zip -r $APP_NAME.app.dSYM.zip "${ARCHIVE_DSYMS_PATH}/$APP_NAME.app.dSYM" curl -F file=@"$APP_NAME.app.dSYM.zip" --header "X-Splunk-Mint-apikey: $API_KEY" --header "X-Splunk-Mint-Auth-Token: $API_TOKEN" "https://symbolicator.splkmobile.com/upload/dsym" -i
API キーやトークンを Git の管理対象に入れたく無い場合
プロジェクトルートディレクトリに mint.plist というファイルを置いて、.gitignore で管理対象にならないようにする。
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>API_KEY</key> <string>API キー</string> <key>API_TOKEN</key> <string>API トークン</string> </dict> </plist>
以下のようなスクリプトを登録する
APP_NAME="アプリ名" API_KEY=$(/usr/libexec/PlistBuddy -c "Print API_KEY" $(dirname ${WORKSPACE_PATH})/mint.plist) API_TOKEN=$(/usr/libexec/PlistBuddy -c "Print API_TOKEN" $(dirname ${WORKSPACE_PATH})/mint.plist) rm -f $APP_NAME.app.dSYM.zip zip -r $APP_NAME.app.dSYM.zip "${ARCHIVE_DSYMS_PATH}/$APP_NAME.app.dSYM" curl -F file=@"$APP_NAME.app.dSYM.zip" --header "X-Splunk-Mint-apikey: ${API_KEY}" --header "X-Splunk-Mint-Auth-Token: ${API_TOKEN} "https://symbolicator.splkmobile.com/upload/dsym" -i