2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-06-03 14:03:17 -07:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIURI;
|
2010-10-06 10:07:39 -07:00
|
|
|
interface nsIObserver;
|
2010-06-03 14:03:17 -07:00
|
|
|
interface nsIHttpChannel;
|
|
|
|
|
2013-08-02 16:23:18 -07:00
|
|
|
[scriptable, uuid(b20a9242-5732-45bc-9fa0-a178154f2721)]
|
2013-08-02 15:48:37 -07:00
|
|
|
interface nsISiteSecurityService : nsISupports
|
2010-06-03 14:03:17 -07:00
|
|
|
{
|
2013-08-02 16:23:18 -07:00
|
|
|
const uint32_t HEADER_HSTS = 0;
|
|
|
|
const uint32_t HEADER_HKPK = 1;
|
|
|
|
const uint32_t HEADER_OMS = 2;
|
|
|
|
|
2010-06-03 14:03:17 -07:00
|
|
|
/**
|
|
|
|
* Parses a given HTTP header and records the results internally.
|
2013-08-02 16:23:18 -07:00
|
|
|
* Currently the only header type supported is HSTS (aka STS).
|
|
|
|
* The format of the HSTS header is defined by the HSTS specification:
|
|
|
|
* https://tools.ietf.org/html/rfc6797
|
|
|
|
* and allows a host to specify that future HTTP requests should be
|
2010-06-03 14:03:17 -07:00
|
|
|
* upgraded to HTTPS.
|
|
|
|
*
|
2013-08-02 16:23:18 -07:00
|
|
|
* @param aType the type of security header in question.
|
2010-06-03 14:03:17 -07:00
|
|
|
* @param aSourceURI the URI of the resource with the HTTP header.
|
2013-08-02 16:23:18 -07:00
|
|
|
* @param aHeader the HTTP response header specifying security data.
|
2012-06-30 07:34:17 -07:00
|
|
|
* @param aFlags options for this request as defined in nsISocketProvider:
|
|
|
|
* NO_PERMANENT_STORAGE
|
2012-10-15 14:43:57 -07:00
|
|
|
* @param aMaxAge the parsed max-age directive of the header.
|
|
|
|
* @param aIncludeSubdomains the parsed includeSubdomains directive.
|
2010-06-03 14:03:17 -07:00
|
|
|
* @return NS_OK if it succeeds
|
|
|
|
* NS_ERROR_FAILURE if it can't be parsed
|
|
|
|
* NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA
|
|
|
|
* if there are unrecognized tokens in the header.
|
|
|
|
*/
|
2013-08-02 16:23:18 -07:00
|
|
|
void processHeader(in uint32_t aType,
|
|
|
|
in nsIURI aSourceURI,
|
|
|
|
in string aHeader,
|
|
|
|
in uint32_t aFlags,
|
|
|
|
[optional] out unsigned long long aMaxAge,
|
|
|
|
[optional] out boolean aIncludeSubdomains);
|
2010-06-03 14:03:17 -07:00
|
|
|
|
|
|
|
/**
|
2013-08-02 16:23:18 -07:00
|
|
|
* Given a header type, removes state relating to that header of a host,
|
|
|
|
* including the includeSubdomains state that would affect subdomains.
|
|
|
|
* This essentially removes the state for the domain tree rooted at this
|
|
|
|
* host.
|
|
|
|
* @param aType the type of security state in question
|
2012-06-30 07:34:17 -07:00
|
|
|
* @param aURI the URI of the target host
|
|
|
|
* @param aFlags options for this request as defined in nsISocketProvider:
|
|
|
|
* NO_PERMANENT_STORAGE
|
2010-06-03 14:03:17 -07:00
|
|
|
*/
|
2013-08-02 16:23:18 -07:00
|
|
|
void removeState(in uint32_t aType,
|
|
|
|
in nsIURI aURI,
|
|
|
|
in uint32_t aFlags);
|
2013-08-05 13:18:06 -07:00
|
|
|
|
|
|
|
/**
|
2013-08-02 16:23:18 -07:00
|
|
|
* See isSecureURI
|
2013-08-05 13:18:06 -07:00
|
|
|
*
|
2013-08-02 16:23:18 -07:00
|
|
|
* @param aType the type of security state in question.
|
|
|
|
* @param aHost the hostname (punycode) to query for state.
|
2013-08-05 13:18:06 -07:00
|
|
|
* @param aFlags options for this request as defined in nsISocketProvider:
|
|
|
|
* NO_PERMANENT_STORAGE
|
|
|
|
*/
|
2013-08-02 16:23:18 -07:00
|
|
|
boolean isSecureHost(in uint32_t aType,
|
|
|
|
in string aHost,
|
|
|
|
in uint32_t aFlags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the given security info is for a host with a broken
|
|
|
|
* transport layer (certificate errors like invalid CN).
|
|
|
|
*/
|
|
|
|
boolean shouldIgnoreHeaders(in nsISupports aSecurityInfo);
|
2010-06-03 14:03:17 -07:00
|
|
|
|
|
|
|
/**
|
2013-08-02 16:23:18 -07:00
|
|
|
* Checks whether or not the URI's hostname has a given security state set.
|
|
|
|
* For example, for HSTS:
|
|
|
|
* The URI is an HSTS URI if either the host has the HSTS state set, or one
|
|
|
|
* of its super-domains has the HSTS "includeSubdomains" flag set.
|
|
|
|
* NOTE: this function makes decisions based only on the
|
2010-06-03 14:03:17 -07:00
|
|
|
* host contained in the URI, and disregards other portions of the URI
|
|
|
|
* such as path and port.
|
|
|
|
*
|
2013-08-02 16:23:18 -07:00
|
|
|
* @param aType the type of security state in question.
|
2010-06-03 14:03:17 -07:00
|
|
|
* @param aURI the URI to query for STS state.
|
2012-06-30 07:34:17 -07:00
|
|
|
* @param aFlags options for this request as defined in nsISocketProvider:
|
|
|
|
* NO_PERMANENT_STORAGE
|
2010-06-03 14:03:17 -07:00
|
|
|
*/
|
2013-08-02 16:23:18 -07:00
|
|
|
boolean isSecureURI(in uint32_t aType, in nsIURI aURI, in uint32_t aFlags);
|
2010-06-03 14:03:17 -07:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
%{C++
|
2013-08-02 15:48:37 -07:00
|
|
|
#define NS_SSSERVICE_CONTRACTID "@mozilla.org/ssservice;1"
|
2010-06-03 14:03:17 -07:00
|
|
|
|
|
|
|
#define STS_PERMISSION "sts/use"
|
|
|
|
#define STS_SUBDOMAIN_PERMISSION "sts/subd"
|
|
|
|
%}
|