• Api Documentation
Show / Hide Table of Contents
  • Softadmin.Api
    • AdminMessageException
    • CustomComponent
    • ICookies
    • ICredentialsStore
    • IEnvironment
    • IForwardState
    • IHttpHeaders
    • IParameters
    • ISessionVariables
    • ISystemSettings
    • Plugin
  • Softadmin.Api.Database
    • IDbRequest
    • IDbRequestFactory
  • Softadmin.Api.Diagnostics
    • ILogger
  • Softadmin.Api.Login
    • IUserState
    • LoginPlugin
    • PostLoginPlugin
    • PreLoginPlugin
    • UserAuthenticationPlugin
  • Softadmin.Api.Logout
    • LogoutPlugin
  • Softadmin.Api.Page
    • ICustomPage
    • PagePlugin
  • Softadmin.Api.Ui
    • IDebugWindow
    • IProgressWindow

Interface ICookies

Provides read-only access to the HTTP cookies.

Namespace: Softadmin.Api
Assembly: Softadmin.Api.dll
Syntax
public interface ICookies
Examples

Implements single sign-on where an external proxy passes a cookie to the login page describing the identity of the user.

public class SsoCookiePlugin : PreLoginPlugin
{
	public override void BeforeLogin()
	{
		var ssoUserId = this.Cookies["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 a given cookie.

Declaration
string this[string name] { get; }
Parameters
Type Name Description
System.String name

Name of cookie, case insensitive.

Property Value
Type Description
System.String

Value, or null if the cookie is not present.

Back to top Generated by DocFX