将经过身份验证的用户从sharepoint传递到asp mvc应用程序

时间:2012-01-30 14:11:57

标签: asp.net-mvc asp.net-mvc-3 sharepoint asp.net-mvc-2 sharepoint-2010

我已经制作了具有自定义表单身份验证的asp.net mvc应用程序。 除此之外,它需要从sharepoint验证用户(换句话说,我需要将用户从sharepoint传递到asp mvc应用程序)。 SP和asp mvc应用程序位于同一个域中,SP使用AD对用户进行身份验证。我搜索过Google /所以到目前为止我还没有得到任何好的解决方案。

注意:我需要将用户从sp传递到asp mvc应用程序的安全方式...我看到几个传递用户思想URL参数的示例,我认为这不是安全的事情。

2 个答案:

答案 0 :(得分:2)

为什么不使用url paramenter?

public class SecureToken {
    public Int32 UserId {get;set;}
    public DateTime DateCreated {get;set;}
    public DateTime ValidTill {get;set;}

    public SecureToken (Int32 userId) {
        this.UserId = userId;
        this.DateCreated = DateTime.Now;
        this.ValidTill = this.DateCreated.AddMinutes(0.5);
    }
    public String ToEncryptedToken() {
        // Do serialization,
        // Then encrypt with, for example TrippleDES
        // Escape for url
        // return the string arguement for url
    }

    public static SecureToken Decrypt(String input) {
        // If the DateCreated == ValidTill - 30 seconds
        // If validTill > Now
        // If decryptable
        // Return deserialized token
        // else throw Authentication error.
    }
}

这里的要点是URL中的令牌仅可存活30秒。 作为一个附加参数,您可以在序列化期间使用HMAC-SHA 256并检查天气这确实是您的令牌。

答案 1 :(得分:0)

您可以为自定义表单身份验证提供程序配置SP,该提供程序又会对域进行验证 - 然后您在应用程序之间共享表单身份验证令牌,这非常简单:

http://msdn.microsoft.com/en-us/library/ie/eb0zx8fc.aspx

相关问题