SSO およびプラス記号を含む電子メールアドレス

I’m not sure if this is an implementation error on my side or if this is a bug in the SSO implementation of Discourse.
Users having a plus-extension in the local part of their e-mail address got an error since Discourse interpretes the plus sign as space.

Following Official Single-Sign-On for Discourse (sso) I must not urlencode the payload before encoding it to base64.

Here my basic implementation, written in php:

$email = 'user+extension@example.com';
$payload = base64_encode($nonce. "&email={$email}&external_id={$external_id}&username={$realname}&name={$realname}");
$return_sig = hash_hmac('sha256', $payload, $token);
header("Location: $referer/session/sso_login?sso=". rawurlencode($payload) ."&sig=". $return_sig);

Discourse throws the error: “Nonce has already expired” and writes down the e-mail address as “user extension@example.com” with a space instead of a plus sign.

「いいね!」 1

You need "nonce=" . $nonce. there…

「いいね!」 3

This is already there and was not the reason for my request.

(
    $nonce = base64_decode($sso);
    # starts with nonce=...
)

少し遅くなりましたが、もし他の誰かにもこの問題が発生した場合のために投稿します。

実際には、base64 エンコードする前にペイロードを URL エンコードすべきです。当社の WordPress プラグイン および Ruby 実装 は、どちらもペイロードを構築するためにライブラリ関数を使用しており、これによりエンコードが自動的に処理されます。

ドキュメントをより明確にするために更新しました。

「いいね!」 3

このトピックは6日後に自動的に閉鎖されました。新しい返信は受け付けられていません。