Closed Bug 1485177 Opened Last year Closed Last year

Expose the |site| on nsIPrincipal

Categories

(Core :: Security: CAPS, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: Nika, Assigned: Nika)

Details

(Whiteboard: [domsecurity-active])

Attachments

(1 file, 2 obsolete files)

This will make it easier in the future to encode certain behaviours which depend on a principal's |site|. The basic restriction of a site is that two documents with different sites may never be Same-Origin-Domain (a.k.a. they will never be considered |subsumesConsideringDomain|).
Component: DOM: Security → Security: CAPS
Priority: -- → P2
Whiteboard: [domsecurity-active]
Depends on D4702
Attachment #9005268 - Attachment is obsolete: true
Attachment #9005269 - Attachment is obsolete: true
Comment on attachment 9003582 [details]
Bug 1485177 - Add |siteOrigin| information to nsIPrincipal

:Ehsan Akhgari has approved the revision.
Attachment #9003582 - Flags: review+
Pushed by nlayzell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/33c7b0ea5caa
Add |siteOrigin| information to nsIPrincipal, r=Ehsan
Would be good to coordinate this with the work in bug 1487032.
(In reply to Bobby Holley (:bholley) from comment #7)
> Would be good to coordinate this with the work in bug 1487032.

I think I could use this for bug 1487032, but ContentPrincipal::GetSiteOrigin will be too slow to call on each wrap operation. 

How do people feel about caching that string in BasePrincipal? I suppose I could also call GetSiteOrigin when creating the CompartmentPrivate and then cache it there...
Actually for bug 1487032 I think we have to do a subsumes check to support

  Wrap(Compartment-With-ExpandedPrincipal, Compartment-With-ContentPrincipal)

Because here we want to return a transparent wrapper if the expanded principal subsumes the other principal (and an opaque wrapper otherwise)?

bholley suggested returning a new principal representing the site, but I think I can build that on top of GetSiteOrigin added here.

Nika, for your use case we don't have to worry about comparing an expanded principal to a content principal?
(In reply to Jan de Mooij [:jandem] from comment #8)
> (In reply to Bobby Holley (:bholley) from comment #7)
> > Would be good to coordinate this with the work in bug 1487032.
> 
> I think I could use this for bug 1487032, but
> ContentPrincipal::GetSiteOrigin will be too slow to call on each wrap
> operation. 

Definitely - We can make it fast if we need though.

> How do people feel about caching that string in BasePrincipal? I suppose I
> could also call GetSiteOrigin when creating the CompartmentPrivate and then
> cache it there...

I'd be fine with caching the value for ContentPrincipal objects, for non-ContentPrincipal objects, we already cache it (as it's just the origin).

I just didn't use it for this case, because I didn't see performance as relevant for the use case I had in mind.

(In reply to Jan de Mooij [:jandem] from comment #9)
> Actually for bug 1487032 I think we have to do a subsumes check to support
> 
>   Wrap(Compartment-With-ExpandedPrincipal, Compartment-With-ContentPrincipal)
> 
> Because here we want to return a transparent wrapper if the expanded
> principal subsumes the other principal (and an opaque wrapper otherwise)?
> 
> bholley suggested returning a new principal representing the site, but I
> think I can build that on top of GetSiteOrigin added here.

Yeah, I think that makes sense as an approach to take.

> Nika, for your use case we don't have to worry about comparing an expanded
> principal to a content principal?

I don't think we'd have to worry about that in my case, as expanded principals don't often show up in the environment which I'd be wanting to use these. 

I think we could make ExpandedPrincipal call a method which performs the comparison with it's inner principals, which could have the desired effect? Not sure.
Makes sense. After your patch lands I can just make my changes on top of it I think, it definitely helps :)
Attachment #9003582 - Attachment description: Bug 1485177 - Add |siteOrigin| information to nsIPrincipal, r=ehsan → Bug 1485177 - Add |siteOrigin| information to nsIPrincipal
Pushed by nlayzell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/434d6bf22d1d
Add |siteOrigin| information to nsIPrincipal r=Ehsan
https://hg.mozilla.org/mozilla-central/rev/434d6bf22d1d
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Flags: needinfo?(nika)
You need to log in before you can comment on or make changes to this bug.