Under construction
They usually go together: Login with username/password (Authentication) and then access specific resources exclusive to a role, e.g. Admin, Purchaser, Supplier (Authorization) But it doesn't have to be. The concepts are orthogonal.
A claim is a statement that one subject makes about itself or another subject. The statement can be about a name, identity, key, group, privilege, or capability, for example. Claims are issued by a provider, and they are given one or more values and then packaged in security tokens that are issued by an issuer, commonly known as a security token service (STS).
[RFC7617] For example, given an authenticated request to: http://example.com/docs/index.html requests to the URIs below could use the known credentials: http://example.com/docs/ http://example.com/docs/test.doc http://example.com/docs/?page=1 while the URIs http://example.com/other/ https://example.com/docs/ would be considered to be outside the authentication scope.
$ curl --user 'uid:pass' https://mysite.com/path/to/resource
UserID:Password
directlySystem.Web.Mvc.ActionFilterAttribute
OnActionExecuting
:
public class BasicAuthenticationAttribute : ActionFilterAttribute
{
public string BasicRealm { get; set; }
public BasicAuthenticationAttribute(string realm)
{
this.BasicRealm = realm;
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var auth = filterContext.HttpContext.Request.Headers["Authorization"];
if (!String.IsNullOrEmpty(auth))
{
var cred = System.Text.ASCIIEncoding.ASCII.GetString(
Convert.FromBase64String(auth.Substring(6))).Split(':');
var user = new { Name = cred[0], Pass = cred[1] };
//if (user.Name == Username && user.Pass == Password && ) return;
}
filterContext.HttpContext.Response.AddHeader("WWW-Authenticate",
String.Format("Basic realm=\"{0}\"", BasicRealm));
filterContext.Result = new HttpUnauthorizedResult();
// Watch out: returning unauthorized (401) is intercepted by default
// by Identity and instead returns an error page with code 200, which isn't what you want
}
}
[BasicAuthenticationAttribute("Data Upload Realm")]
public class UploadController : Controller
{
[HttpPost]
public ActionResult NewRecords()
{
//...
}
}
set-cookie:fr=0LR4grqIfc8FVKsGb..BaikXz.6-.AAA.0.0.BaikXz.AWW6VSNR; expires=Sun, 20-May-2018 03:35:15 GMT; Max-Age=7776000; path=/; domain=.facebook.com; secure; httponly
Response.Cookies["userName"].Value = "patrick";
Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1);
// or
HttpCookie aCookie = new HttpCookie("lastVisit");
aCookie.Value = DateTime.Now.ToString();
aCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(aCookie);
Document.cookie
"Confidential or sensitive information should never be stored or transmitted in HTTP Cookies, as the entire mechanism is inherently insecure." [MDN HTTP cookies]
Authorization: Bearer
header,Source of image:Bitcoin: Technical Background and Data Analysis
Each time the server receives a token in a request...
From: Auth0
Microsoft.Owin.Security.Cookies
Microsoft.Owin.Security.OAuth
Microsoft.Owin.Security.Jwt
Database Diagram (.pdf) + Example in use using Option 1