1775022813
2026-04-01 04:54:00
有効化 オクタ SSO における認証とセキュリティのモデルを大幅に強化しました。 CMSを最適化する。ただし、現実世界の多くの実装と同様に、システムが Okta ID をユーザー名として保存するようになったため、CMS オーサリング エクスペリエンスに予期せぬ課題も発生しました。
問題:
SSO に切り替えた後、ユーザー ID の保存方法に変化が見られました。
- の 「発行者」 フィールドに表示される Okta ID
- 編集者は名前や電子メールの代わりに技術 ID を見ました
編集費への影響
これにより、コンテンツ チームに摩擦が生じました。
- 著者の帰属が不明瞭になった
- コンテンツレビューを追うのが難しかった
- 監査は人間が判読できるコンテキストを失った
技術者以外のユーザーにとって、これはユーザビリティの顕著な低下でした。
解決:
これに対処するために、カスタム変換を導入しました。
👉 発行者Transform
この変換は、保存されている Okta 識別子を わかりやすい表示値、 のような:
- 著者名
- 電子メールアドレス
- または読み取り可能な ID フィールド
生の Okta ID を公開する代わりに、CMS は意味のあるユーザー情報を解決して表示するようになりました。
[ServiceConfiguration(typeof(IModelTransform), Lifecycle = ServiceInstanceScope.Singleton)]
public class PublishedByTransform : ContentDataStoreModelTransform
{
private readonly EPiServer.Logging.ILogger _logger;
private readonly IUserService _userService;
private readonly IPrincipalAccessor _principalAccessor;
private readonly IContentVersionRepository _contentVersionRepository;
public PublishedByTransform(
IUserService userService,
IPrincipalAccessor principalAccessor,
IContentVersionRepository contentVersionRepository)
{
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
_principalAccessor = principalAccessor ?? throw new ArgumentNullException(nameof(principalAccessor));
_contentVersionRepository = contentVersionRepository ?? throw new ArgumentNullException(nameof(contentVersionRepository));
_logger = LogManager.GetLogger(typeof(PublishedByTransform));
}
public override void TransformInstance(IContent source, ContentDataStoreModel target, IModelTransformContext context)
{
base.TransformInstance(source, target, context);
ContentVersion contentVersion1 = this._contentVersionRepository.Load(source.ContentLink);
ContentVersion contentVersion2 = _contentVersionRepository.LoadPublished(source.ContentLink, source.LanguageBranch());
if (contentVersion1 != null)
{
var versionCreatedBy = string.IsNullOrEmpty(contentVersion1.StatusChangedBy) ? contentVersion1.SavedBy : contentVersion1.StatusChangedBy;
target.VersionCreatedBy = ResolvePublishedBy(versionCreatedBy);
}
if (contentVersion2 != null)
{
var publishedBy = !string.IsNullOrWhiteSpace(contentVersion2.StatusChangedBy)
? contentVersion2.StatusChangedBy
: contentVersion2.SavedBy;
target.PublishedBy = ResolvePublishedBy(publishedBy);
}
}
private string? ResolvePublishedBy(string? publishedBy)
{
if (string.IsNullOrWhiteSpace(publishedBy))
return publishedBy;
try
{
var user = _userService.GetUserByName(publishedBy);
if (user == null)
return publishedBy;
var claimsPrincipal = _principalAccessor.Principal as ClaimsPrincipal;
var currentUserEmail = claimsPrincipal?.FindFirst("email")?.Value ?? claimsPrincipal?.FindFirst(ClaimTypes.Email)?.Value;
if (!string.IsNullOrWhiteSpace(currentUserEmail)
&& !string.IsNullOrWhiteSpace(user.Email)
&& string.Equals(currentUserEmail, user.Email, StringComparison.OrdinalIgnoreCase))
{
return "you";
}
return !string.IsNullOrWhiteSpace(user.Email) ? user.Email : user.UserName;
}
catch (Exception ex)
{
_logger.Error($"PublishedByTransform failed to resolve PublishedBy for value '{publishedBy}'. Error: {ex}");
return publishedBy;
}
}
}
結果:
この小さいながらも影響力のある機能強化により、次の両方の長所を実現しました。
- Okta を介した安全な SSO は完全に維持されます
- 「発行者」に明確で読みやすい著者名が表示されるようになりました

ブログをお読みいただきありがとうございます。乾杯!
2026 年 4 月 1 日
#Optimizely #CMS #での #OKTA #SSO #後の発行者の修正