Interface IHttpHeaders
Provides access to the HTTP headers passed with the page request.
Namespace: Softadmin.Api
Assembly: Softadmin.Api.dll
Syntax
public interface IHttpHeaders
Examples
Implements single sign-on where an external proxy passes an extra HTTP-header to the login page describing the identity of the user.
public class SsoHttpHeaderPlugin : PreLoginPlugin
{
public override void BeforeLogin()
{
var ssoUserId = this.HttpHeaders["MyUserId"];
if (!string.IsNullOrEmpty(ssoUserId))
{
this.UserState.UserId = this.ConvertUserId(ssoUserId);
}
}
private int ConvertUserId(string ssoUserId)
{
using (var request = this.RequestFactory.CreateRequest("Convert external user id to local"))
{
request.SetParameter("SsoUserId", ssoUserId);
var dataSet = request.GetDataSet();
var table = dataSet.Tables[0];
if (table.Rows.Count == 0)
{
throw new Exception($"Unknown external user id {ssoUserId}.");
}
return (int)table.Rows[0]["UserId"];
}
}
}
Properties
Item[String]
Gets the value of the given HTTP header.
Declaration
string this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name |
Property Value
Type | Description |
---|---|
System.String | The value, or |