ログイン後にパスワード変更を強制

こんにちは、

フォーラムを Discourse に移行しています。discourse-migratepassword プラグインと同じアプローチを使用して、ユーザーが現在のパスワードでログインできるようにしていますが、これらのパスワードは安全でない可能性があります。

ユーザーにログインを許可しつつ、Discourse のパスワード設定に準拠していない場合はログイン後にパスワード変更を強制したいと考えています。

現在、このような機能を実装する方法はありますか?もしない場合、プラグインとして実装するにはどこを確認すべきでしょうか?

ありがとうございます!

Sounds like it would be useful as an option on the discourse-migratepassword plugin. Slightly surprised it isn’t already.

Yeah, we can use that in the plugin too, happy to contribute that back if I implement it.

I was thinking in adding a custom_field to the user and render an alert until the user changes their password, but forcing them to change it sounds like a better option (not sure where to look to achieve this)

Well, I’m not forcing users to change their password, but we are rendering an alert on every login until they do so.

I’m setting a user.custom_fields['migratepassword_policy'] = true if the password doesn’t comply with Discourse settings and using that to conditionally render the modal, and we also send a password reset email once after they log in for the first time (with the insecure password)

What do you guys think?

I think it was enabled without an option in the past - if your password was too short, you were required to do a password reset instead.

The policy was flipped because this was locking people out of their accounts (dead email accounts).

Yeah, in this case we allow users to get into the platform with their current password, but we will render that modal until they change it (they can click OK or click outside the modal and it will close)

Maybe adding a “contact support if you don’t have access to your email anymore” message will do in case of dead email accounts

こんにちは、まさに同じことが必要です。API を介してユーザーを作成し、デフォルトのパスワードを設定します。ユーザーが初めてログインした後、パスワードを変更する必要があります。

どのように実装しましたか?

ありがとうございます!

デフォルトのパスワードでユーザーを作成するのではなく、ランダムなパスワードでユーザーを作成し、そのパスワードをユーザーに送信しないようにしてください。その後、ユーザーはログインページにある「パスワードをお忘れですか」リンクを使用して、ログイン前にパスワードをリセットできます。

99%のユーザーがメールアドレスを持っていません^^。また、「パスワード再設定メール」のためだけに大量のメールを追加したくありません。

実在のメールアドレスを使用する以外に方法はありませんか?

それは大きな問題になります。Discourse では、メールアドレスがアイデンティティとみなされているためです。

ログインプロセスを完全に制御し、標準に準拠したい場合は、Discourse の公式シングルサインオン (SSO) の使用をお勧めします。

Discourse は、パスワードを期限切れにするネイティブ機能をサポートするようになりました。

これを行うには、以下を実行する必要があります。

user = User.find_by_username(username)
UserPasswordExpirer.expire_user_password(user)

これは、ホストされている顧客の場合は Discourse スタッフが行うか、コンテナに入り、Rails コンソールを実行して、特定のユーザーに対してこれを実行することで行うことができます。