You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Terry Poot <tp...@goldenvoid.com> on 2004/08/09 00:11:08 UTC

data transmission security

I'm a newbie to Tapestry (still reading the book), but have read the 
excellent conversation thread between Paul Ferraro and F. Da Costa 
regarding SSL-enabling links and forms in Tapestry. (Incidentally, I 
don't see the code from F. Da Costa on the list implementing secure link 
and form components. Was it ever posted?)

I have some thoughts on this from a conceptual view, and a proposal for 
Tapestry that might be considered for a future revision. I'm sorry for 
the length of this, but I felt I needed the explanations for this to 
make any sense. I hope I succeeded in that. :)

CONCEPTUAL

Application frameworks don't generally take HTTPS into account in their 
design. I suspect the reason for this is that it simply doesn't fit 
cleanly into the model, for several reasons.

1. It is a property of the wire protocols, and nobody wants to work at 
that level. Howard repeatedly makes the point in the book that Tapestry 
is meant to get you to a higher level than working at the http response 
request cycle, where all this stuff lives.

2. Security is not properly a concern of the View component of the MVC 
architecture. The J2EE model makes it one, because of its reliance on 
URL's, but that model has other problems in any case (that would be a 
separate diatribe). The security model of an application is just that: a 
model concern. Implementing it would be a controller concern. The view 
might render things differently because of the decisions made by the 
controller as informed by the model, but it doesn't care why or how 
those decisions were made, or that they are security related, nor should 
it.

There are 2 additional complications that screw it all up even further: 
user perception and browers-induced confusion. These are related. Users 
think that pages are secure, not transmissions, because the browser 
shows them a security icon for a page that they have received via HTTPS. 
That does indeed mean the data was sent securely. However, if they don't 
see that indicator (the ubiquitous golden lock icon) they won't believe 
their data will be SENT securely, which of course it could be if the 
page specifies the proper URL. The browsers contribute to this with the 
infamous "some parts of this page are insecure" types of warnings, 
enforcing the perception that the page they are looking at has to be 
"secure" for their data to be protected.

Because of the user perception issue, in order for a user to be willing 
to enter a password or credit card number, the application has to send 
the page that requests it via a secure link. Unfortunately, that isn't 
possible in the literal sense. The application can't switch to SSL, the 
browser has to. That means that the page that displays the form must be 
requested by a page that knows the form needs to be sent securely. We've 
now had to back up by one full request/response cycle. Instead of the 
form transmission being secure (which it still has to be), the request 
for the page containing the form has to specify HTTPS, and the 
application then must send a form that also specifies HTTPS, or at least 
uses a relative url so it continues to use HTTPS.

Because of all this, data transmission security must be handled by the 
view layer, because that's the part of  MVC model that generates the 
component that requests the form that must be secure. In a word: YUK. 
It's no real wonder that this doesn't fit cleanly into anyone's model. 
Even struts, which lives at the request/response level, doesn't handle 
this, you need the SSLEXT extension.

In effect, however, what we are doing is specifying a property of the 
data transmission. And because the browser, and not the app, is in 
control, we have to tell the browser, in the iteration before the 
transmission in question, just what it needs to ask us to do.

PRAGMATIC

Because of all this, I think F. Da Costa's mechanism is the proper one, 
though we might all wish that weren't the case. In Tapestry terms, some 
component must request that the transmission be secure, because that's 
really the only place it can be done (assuming that a: we don't want to 
use HTTPS unless we have to because of the expense, and b: we only have 
to in certain limited circumstances). For the user to be happy about it, 
this has to happen a page sooner than strictly required (though it might 
be required that soon if the secure form will be preloaded with 
sensitive data, since the request must be secure before the response can 
be). These components can hack the link to make this happen.

This leads me to a question, however. As I understand it, Tapestry will 
preserve the port and scheme from the request in generated URL's on the 
rendered page. So, how do we get OUT of SSL? Once we have returned the 
secure data, if any, from the secure transmission, are all the links on 
that page going to use SSL, because they preserve the schema and port 
from the request? Or will those ALWAYS specify HTTP and port 80 unless 
we specifically use a secure component? The latter behavior, while more 
convenient in this case, would certainly make writing an app that runs 
on an alternate port a pain.

If the scheme and port are preserved, it almost seems that we need 
subclasses of link and form components that specify several different 
security options, and we have to use them anywhere we might need to 
transition from one to the other. In otherwords, on the login succesful 
page, we need a link to the home page that very specifically turns off 
HTTPS by specifying http and port 80. And if you want a succesful login 
to go to the home page, every link and form on the home page has to do 
this. Theoretically, a large percentage of the links and forms in an 
application might need to specify the security. In fact, the SSLEXT 
structs extension does this, you can specify that security be turned on, 
off, or left however it is, and you pretty much use their tags instead 
of the struts version throughout your app. I suppose that's about the 
best fit you'll get in the struts model, but I think Tapestry can do better.

PROPOSAL

What we're specifying, conceptually, are data transmission properties. 
But because we can only specify these in the URL, it's more useful to 
think of them as URL properties. Security is the obvious one, however, 
in search of a contrived example, let's say a company had a standard 
whereby certain information could only be served via web applications 
that were accessed through a specific port that was blocked by the 
company's firewall, and applications were required to enforce this by 
only providing internal data to requests received on this port. These 
transmissions could be considered to have the property "internal", as 
opposed to secure. The solution in Tapestry would be identical in form 
to secure transmissions. Now let's further assume that someone might 
someday want to change just which port the internal data is served from. :)

A somewhat less contrived example would be in tying into J2EE 
declarative security, which is URL based. While this is, strictly 
speaking, a property of the URL and not the data transmission, it still 
happens at the same place, the href or action attribute of the 
corresponding HTML element.

A possible solution to this would be for the components that generate 
links and forms (the only chance we get to tell the browser how to talk 
back to us) would support the ability to set a connection property on 
that link. This could be an arbitrary value, though for convenience, the 
value "secure" could be predefined. We could then determine what this 
means at the application level, by defining a family of link renderers, 
corresponding to the different connection properties used in our 
application. (Hmm, see below for a better idea on that.)

I don't know if at the bottom of it all there's one link rendering class 
that does all the work for the various rendering classes, but if so, 
that would simplify the implementation of this greatly, in that it would 
allow you to impose specific patterns on the generated URLS. A "secure" 
link would use a renderer that forced HTTPS and port 443. An "insecure" 
link would force hhtp and port 80. An "internal" link would use a 
renderer that forced an alternate port.

And, for people using J2EE security, a "customer service" link could 
enforce a particular URL pattern defined to J2EE as requiring a 
particular security role. This case would require some "link de-hacking" 
in Tapestry to restore the link so that it could be handled properly. Or 
would it? I haven't read that chapter yet, perhaps everything Tapestry 
needs is in the request parameters, and as long as it gets to the 
Tapestry servlet, the path information doesn't matter?

Of course, if Tapestry preserves path, scheme and port info, we need to 
revert any of these things back to the default scheme, path and port at 
the right time, so perhaps a different mechanism is needed to "revert" 
the link, rather than specifying "insecure" to turn off HTTPS, and 
"external" to turn off "internal", etc. (As a side benefit, this 
mechanism allows one to easily change what that default is.) Also, 
potentially, these could be stackable, where we could have both secure 
and internal separately specified, or have the role independent of the 
transmission security (though I think J2EE can specify this, but with 
what level of granularity, and how much XML?).

With this mechanism in place, it wouldn't actually be too unreasonable 
for all links to be forced to "normal" unless otherwise specified, thus 
solving the "revert" problem. That's also a lot safer in that if the 
application flow changes, you can't flow into a page that thinks the 
page before it set the security so it doesn't have to. And of course, 
with the ability to specify what "normal" is, if you need the whole app 
to be SSL, you only have to say so once, in the default link properties.

In the end, this amounts to the same thing as F. Da Costa's solution, in 
so far as the security aspect is concerned, but with a lot less coding 
required of the application programmer. However, the solutions I've seen 
mentioned for the J2EE security problem are completely different (and 
beyond my current understanding of the machinery under the hood). I 
don't know how it compares to those, but it seems to require less coding 
there as well. In either case, it provides a useful abstraction so 
people don't have to know enough about all these mechanisms to implement 
those components. That is, after all, what a framework is for, to worry 
about these sorts of things so that we don't have to, any more than 
letting the framework know what we require of it, something that 
Tapestry does exceedingly well in most areas.

At the worst case, the most you'd need would be a custom link renderer 
to support properties that didn't already come defined. And one could 
easily see the standard renderer being extended to do this task based on 
declarative rules rather than having to code it, at least for more 
common situations. Forcing a scheme, port or path prefix  should be 
easily declared. And again, in the J2EE case, this would let you simply 
declare a path prefix for each role matching your J2EE security 
declarations, and then tagging your links and forms with the role 
required to access that functionality. That may break down with multiple 
permissible roles, but someone who has actually used, rather than merely 
read about, J2EE security would have to answer that.

I'm going to stop here, as I don't really know Tapestry well enough yet 
to suggest specific mechanisms. If the idea has any merit, perhaps 
others will fill that in, or I can talk more about it after I learn a 
bit more. As F. Da Costa has proven, all this is doable with the 
facilities we already have, but having it built in would be very slick, 
IMHO.

FOOTNOTE

I actually identified Tapestry as the web application technology for a 
project over a year ago, and then got sidetracked from that project 
until now, but I have nearly a year and a half of mailing list messages 
on my machine and searchable. Now I'm trying to get up to speed quickly, 
and that message archive is proving invaluable. Kudos to Howard, and 
everyone in the Tapestry community for the quality of the model, the 
software, and the discussions surrounding it.

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: data transmission security

Posted by F Da Costa <da...@xs4all.nl>.
Terry Poot wrote:
> Fermin: thanks for the code! Also thanks for the warning on the hard 
> coded port numbers. :) I'll need to change those to 443 in a few places.
Noop, it will support going from 80 or 8080 to secure 443 and 8443 
respectively. It looks at where you started from and takes it from there.

> This will get me what I need until/unless Tapestry comes up with a 
> better mechanism. Just the fact that you had to copy the whole form 
> component and change it rather than being able to subclass it as with 
> the link classes is a good indication that something needs to be done on 
> the framework side.
Ah, i haven't even looked at that. Quite possible that one could 
actually do that but i couldn't be bother as i did not know what i had 
to change. So i copied it all ;-)
> 
> I'm surprised that it reverts to non-secure without you having to do 
> anything to cause this, but that's certainly convenient in this case! I 
> guess at the bottom level it must be generating all absolute links. That 
> does simplify the implementation of my proposal though, you specify 
> secure wherever you need it, and the rest of the time it will go to the 
> defaults.
Yep, that's the whole idea
> 
> I'm also a bit surprised this topic died out before. It's hard to 
> imagine a "real world" application that doesn't run into this, and I 
> can't think of how else others might be dealing with this.
Dunno, but he, if its of use to you than thats fine.


> 
> F Da Costa Gomez wrote:
> 
>> Hi Terry,
>>
>> Terry Poot wrote:
>>
>>> I'm a newbie to Tapestry (still reading the book), but have read the 
>>> excellent conversation thread between Paul Ferraro and F. Da Costa 
>>> regarding SSL-enabling links and forms in Tapestry. (Incidentally, I 
>>> don't see the code from F. Da Costa on the list implementing secure 
>>> link and form components. Was it ever posted?)
>>>
>> I thought I did but no worries. Please find attached.
>> A small note though. As i'm *by no means* a developer i just tend to 
>> get things to work reasonably. Making it perfect? i'm more than happy 
>> to leave that into more capable hands ;-)
>> This is also the reason for the rather 'hardcoded' nature of the 
>> components, i just work with the 80-443 and 8080-8443 combinations. I 
>> guess one could use a property thing to make *both* the ports 
>> variable. If this is already in place i'v just missed it.
>>
>> One additional comment: as you mention further down in your post i'm 
>> moving in and out of secure mode as i want by just using the proper 
>> link-thing. I.e. when on a secure page i just use the normal PageLink 
>> and i'm back in normal mode. A SecureForm on a normal page takes care 
>> of putting that particular form in secure mode (or so it should at 
>> least).
>>
>> I'm not suggesting these components are great but at least they work 
>> just fine for me (incl golden lock etc). I'm not sure why the subject 
>> was never picked up or whether it will this time but if the components 
>> are usefull for you, great.
>>
>> Cheers,
>> Fermin DCG
>>
>>> I have some thoughts on this from a conceptual view, and a proposal 
>>> for Tapestry that might be considered for a future revision. I'm 
>>> sorry for the length of this, but I felt I needed the explanations 
>>> for this to make any sense. I hope I succeeded in that. :)
>>>
>>> CONCEPTUAL
>>>
>>> Application frameworks don't generally take HTTPS into account in 
>>> their design. I suspect the reason for this is that it simply doesn't 
>>> fit cleanly into the model, for several reasons.
>>>
>>> 1. It is a property of the wire protocols, and nobody wants to work 
>>> at that level. Howard repeatedly makes the point in the book that 
>>> Tapestry is meant to get you to a higher level than working at the 
>>> http response request cycle, where all this stuff lives.
>>>
>>> 2. Security is not properly a concern of the View component of the 
>>> MVC architecture. The J2EE model makes it one, because of its 
>>> reliance on URL's, but that model has other problems in any case 
>>> (that would be a separate diatribe). The security model of an 
>>> application is just that: a model concern. Implementing it would be a 
>>> controller concern. The view might render things differently because 
>>> of the decisions made by the controller as informed by the model, but 
>>> it doesn't care why or how those decisions were made, or that they 
>>> are security related, nor should it.
>>>
>>> There are 2 additional complications that screw it all up even 
>>> further: user perception and browers-induced confusion. These are 
>>> related. Users think that pages are secure, not transmissions, 
>>> because the browser shows them a security icon for a page that they 
>>> have received via HTTPS. That does indeed mean the data was sent 
>>> securely. However, if they don't see that indicator (the ubiquitous 
>>> golden lock icon) they won't believe their data will be SENT 
>>> securely, which of course it could be if the page specifies the 
>>> proper URL. The browsers contribute to this with the infamous "some 
>>> parts of this page are insecure" types of warnings, enforcing the 
>>> perception that the page they are looking at has to be "secure" for 
>>> their data to be protected.
>>>
>>> Because of the user perception issue, in order for a user to be 
>>> willing to enter a password or credit card number, the application 
>>> has to send the page that requests it via a secure link. 
>>> Unfortunately, that isn't possible in the literal sense. The 
>>> application can't switch to SSL, the browser has to. That means that 
>>> the page that displays the form must be requested by a page that 
>>> knows the form needs to be sent securely. We've now had to back up by 
>>> one full request/response cycle. Instead of the form transmission 
>>> being secure (which it still has to be), the request for the page 
>>> containing the form has to specify HTTPS, and the application then 
>>> must send a form that also specifies HTTPS, or at least uses a 
>>> relative url so it continues to use HTTPS.
>>>
>>> Because of all this, data transmission security must be handled by 
>>> the view layer, because that's the part of  MVC model that generates 
>>> the component that requests the form that must be secure. In a word: 
>>> YUK. It's no real wonder that this doesn't fit cleanly into anyone's 
>>> model. Even struts, which lives at the request/response level, 
>>> doesn't handle this, you need the SSLEXT extension.
>>>
>>> In effect, however, what we are doing is specifying a property of the 
>>> data transmission. And because the browser, and not the app, is in 
>>> control, we have to tell the browser, in the iteration before the 
>>> transmission in question, just what it needs to ask us to do.
>>>
>>> PRAGMATIC
>>>
>>> Because of all this, I think F. Da Costa's mechanism is the proper 
>>> one, though we might all wish that weren't the case. In Tapestry 
>>> terms, some component must request that the transmission be secure, 
>>> because that's really the only place it can be done (assuming that a: 
>>> we don't want to use HTTPS unless we have to because of the expense, 
>>> and b: we only have to in certain limited circumstances). For the 
>>> user to be happy about it, this has to happen a page sooner than 
>>> strictly required (though it might be required that soon if the 
>>> secure form will be preloaded with sensitive data, since the request 
>>> must be secure before the response can be). These components can hack 
>>> the link to make this happen.
>>>
>>> This leads me to a question, however. As I understand it, Tapestry 
>>> will preserve the port and scheme from the request in generated URL's 
>>> on the rendered page. So, how do we get OUT of SSL? Once we have 
>>> returned the secure data, if any, from the secure transmission, are 
>>> all the links on that page going to use SSL, because they preserve 
>>> the schema and port from the request? Or will those ALWAYS specify 
>>> HTTP and port 80 unless we specifically use a secure component? The 
>>> latter behavior, while more convenient in this case, would certainly 
>>> make writing an app that runs on an alternate port a pain.
>>>
>>> If the scheme and port are preserved, it almost seems that we need 
>>> subclasses of link and form components that specify several different 
>>> security options, and we have to use them anywhere we might need to 
>>> transition from one to the other. In otherwords, on the login 
>>> succesful page, we need a link to the home page that very 
>>> specifically turns off HTTPS by specifying http and port 80. And if 
>>> you want a succesful login to go to the home page, every link and 
>>> form on the home page has to do this. Theoretically, a large 
>>> percentage of the links and forms in an application might need to 
>>> specify the security. In fact, the SSLEXT structs extension does 
>>> this, you can specify that security be turned on, off, or left 
>>> however it is, and you pretty much use their tags instead of the 
>>> struts version throughout your app. I suppose that's about the best 
>>> fit you'll get in the struts model, but I think Tapestry can do better.
>>>
>>> PROPOSAL
>>>
>>> What we're specifying, conceptually, are data transmission 
>>> properties. But because we can only specify these in the URL, it's 
>>> more useful to think of them as URL properties. Security is the 
>>> obvious one, however, in search of a contrived example, let's say a 
>>> company had a standard whereby certain information could only be 
>>> served via web applications that were accessed through a specific 
>>> port that was blocked by the company's firewall, and applications 
>>> were required to enforce this by only providing internal data to 
>>> requests received on this port. These transmissions could be 
>>> considered to have the property "internal", as opposed to secure. The 
>>> solution in Tapestry would be identical in form to secure 
>>> transmissions. Now let's further assume that someone might someday 
>>> want to change just which port the internal data is served from. :)
>>>
>>> A somewhat less contrived example would be in tying into J2EE 
>>> declarative security, which is URL based. While this is, strictly 
>>> speaking, a property of the URL and not the data transmission, it 
>>> still happens at the same place, the href or action attribute of the 
>>> corresponding HTML element.
>>>
>>> A possible solution to this would be for the components that generate 
>>> links and forms (the only chance we get to tell the browser how to 
>>> talk back to us) would support the ability to set a connection 
>>> property on that link. This could be an arbitrary value, though for 
>>> convenience, the value "secure" could be predefined. We could then 
>>> determine what this means at the application level, by defining a 
>>> family of link renderers, corresponding to the different connection 
>>> properties used in our application. (Hmm, see below for a better idea 
>>> on that.)
>>>
>>> I don't know if at the bottom of it all there's one link rendering 
>>> class that does all the work for the various rendering classes, but 
>>> if so, that would simplify the implementation of this greatly, in 
>>> that it would allow you to impose specific patterns on the generated 
>>> URLS. A "secure" link would use a renderer that forced HTTPS and port 
>>> 443. An "insecure" link would force hhtp and port 80. An "internal" 
>>> link would use a renderer that forced an alternate port.
>>>
>>> And, for people using J2EE security, a "customer service" link could 
>>> enforce a particular URL pattern defined to J2EE as requiring a 
>>> particular security role. This case would require some "link 
>>> de-hacking" in Tapestry to restore the link so that it could be 
>>> handled properly. Or would it? I haven't read that chapter yet, 
>>> perhaps everything Tapestry needs is in the request parameters, and 
>>> as long as it gets to the Tapestry servlet, the path information 
>>> doesn't matter?
>>>
>>> Of course, if Tapestry preserves path, scheme and port info, we need 
>>> to revert any of these things back to the default scheme, path and 
>>> port at the right time, so perhaps a different mechanism is needed to 
>>> "revert" the link, rather than specifying "insecure" to turn off 
>>> HTTPS, and "external" to turn off "internal", etc. (As a side 
>>> benefit, this mechanism allows one to easily change what that default 
>>> is.) Also, potentially, these could be stackable, where we could have 
>>> both secure and internal separately specified, or have the role 
>>> independent of the transmission security (though I think J2EE can 
>>> specify this, but with what level of granularity, and how much XML?).
>>>
>>> With this mechanism in place, it wouldn't actually be too 
>>> unreasonable for all links to be forced to "normal" unless otherwise 
>>> specified, thus solving the "revert" problem. That's also a lot safer 
>>> in that if the application flow changes, you can't flow into a page 
>>> that thinks the page before it set the security so it doesn't have 
>>> to. And of course, with the ability to specify what "normal" is, if 
>>> you need the whole app to be SSL, you only have to say so once, in 
>>> the default link properties.
>>>
>>> In the end, this amounts to the same thing as F. Da Costa's solution, 
>>> in so far as the security aspect is concerned, but with a lot less 
>>> coding required of the application programmer. However, the solutions 
>>> I've seen mentioned for the J2EE security problem are completely 
>>> different (and beyond my current understanding of the machinery under 
>>> the hood). I don't know how it compares to those, but it seems to 
>>> require less coding there as well. In either case, it provides a 
>>> useful abstraction so people don't have to know enough about all 
>>> these mechanisms to implement those components. That is, after all, 
>>> what a framework is for, to worry about these sorts of things so that 
>>> we don't have to, any more than letting the framework know what we 
>>> require of it, something that Tapestry does exceedingly well in most 
>>> areas.
>>>
>>> At the worst case, the most you'd need would be a custom link 
>>> renderer to support properties that didn't already come defined. And 
>>> one could easily see the standard renderer being extended to do this 
>>> task based on declarative rules rather than having to code it, at 
>>> least for more common situations. Forcing a scheme, port or path 
>>> prefix  should be easily declared. And again, in the J2EE case, this 
>>> would let you simply declare a path prefix for each role matching 
>>> your J2EE security declarations, and then tagging your links and 
>>> forms with the role required to access that functionality. That may 
>>> break down with multiple permissible roles, but someone who has 
>>> actually used, rather than merely read about, J2EE security would 
>>> have to answer that.
>>>
>>> I'm going to stop here, as I don't really know Tapestry well enough 
>>> yet to suggest specific mechanisms. If the idea has any merit, 
>>> perhaps others will fill that in, or I can talk more about it after I 
>>> learn a bit more. As F. Da Costa has proven, all this is doable with 
>>> the facilities we already have, but having it built in would be very 
>>> slick, IMHO.
>>>
>>> FOOTNOTE
>>>
>>> I actually identified Tapestry as the web application technology for 
>>> a project over a year ago, and then got sidetracked from that project 
>>> until now, but I have nearly a year and a half of mailing list 
>>> messages on my machine and searchable. Now I'm trying to get up to 
>>> speed quickly, and that message archive is proving invaluable. Kudos 
>>> to Howard, and everyone in the Tapestry community for the quality of 
>>> the model, the software, and the discussions surrounding it.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: data transmission security

Posted by Terry Poot <tp...@goldenvoid.com>.
Fermin: thanks for the code! Also thanks for the warning on the hard 
coded port numbers. :) I'll need to change those to 443 in a few places. 
This will get me what I need until/unless Tapestry comes up with a 
better mechanism. Just the fact that you had to copy the whole form 
component and change it rather than being able to subclass it as with 
the link classes is a good indication that something needs to be done on 
the framework side.

I'm surprised that it reverts to non-secure without you having to do 
anything to cause this, but that's certainly convenient in this case! I 
guess at the bottom level it must be generating all absolute links. That 
does simplify the implementation of my proposal though, you specify 
secure wherever you need it, and the rest of the time it will go to the 
defaults.

I'm also a bit surprised this topic died out before. It's hard to 
imagine a "real world" application that doesn't run into this, and I 
can't think of how else others might be dealing with this.

F Da Costa Gomez wrote:

> Hi Terry,
>
> Terry Poot wrote:
>
>> I'm a newbie to Tapestry (still reading the book), but have read the 
>> excellent conversation thread between Paul Ferraro and F. Da Costa 
>> regarding SSL-enabling links and forms in Tapestry. (Incidentally, I 
>> don't see the code from F. Da Costa on the list implementing secure 
>> link and form components. Was it ever posted?)
>>
> I thought I did but no worries. Please find attached.
> A small note though. As i'm *by no means* a developer i just tend to 
> get things to work reasonably. Making it perfect? i'm more than happy 
> to leave that into more capable hands ;-)
> This is also the reason for the rather 'hardcoded' nature of the 
> components, i just work with the 80-443 and 8080-8443 combinations. I 
> guess one could use a property thing to make *both* the ports 
> variable. If this is already in place i'v just missed it.
>
> One additional comment: as you mention further down in your post i'm 
> moving in and out of secure mode as i want by just using the proper 
> link-thing. I.e. when on a secure page i just use the normal PageLink 
> and i'm back in normal mode. A SecureForm on a normal page takes care 
> of putting that particular form in secure mode (or so it should at 
> least).
>
> I'm not suggesting these components are great but at least they work 
> just fine for me (incl golden lock etc). I'm not sure why the subject 
> was never picked up or whether it will this time but if the components 
> are usefull for you, great.
>
> Cheers,
> Fermin DCG
>
>> I have some thoughts on this from a conceptual view, and a proposal 
>> for Tapestry that might be considered for a future revision. I'm 
>> sorry for the length of this, but I felt I needed the explanations 
>> for this to make any sense. I hope I succeeded in that. :)
>>
>> CONCEPTUAL
>>
>> Application frameworks don't generally take HTTPS into account in 
>> their design. I suspect the reason for this is that it simply doesn't 
>> fit cleanly into the model, for several reasons.
>>
>> 1. It is a property of the wire protocols, and nobody wants to work 
>> at that level. Howard repeatedly makes the point in the book that 
>> Tapestry is meant to get you to a higher level than working at the 
>> http response request cycle, where all this stuff lives.
>>
>> 2. Security is not properly a concern of the View component of the 
>> MVC architecture. The J2EE model makes it one, because of its 
>> reliance on URL's, but that model has other problems in any case 
>> (that would be a separate diatribe). The security model of an 
>> application is just that: a model concern. Implementing it would be a 
>> controller concern. The view might render things differently because 
>> of the decisions made by the controller as informed by the model, but 
>> it doesn't care why or how those decisions were made, or that they 
>> are security related, nor should it.
>>
>> There are 2 additional complications that screw it all up even 
>> further: user perception and browers-induced confusion. These are 
>> related. Users think that pages are secure, not transmissions, 
>> because the browser shows them a security icon for a page that they 
>> have received via HTTPS. That does indeed mean the data was sent 
>> securely. However, if they don't see that indicator (the ubiquitous 
>> golden lock icon) they won't believe their data will be SENT 
>> securely, which of course it could be if the page specifies the 
>> proper URL. The browsers contribute to this with the infamous "some 
>> parts of this page are insecure" types of warnings, enforcing the 
>> perception that the page they are looking at has to be "secure" for 
>> their data to be protected.
>>
>> Because of the user perception issue, in order for a user to be 
>> willing to enter a password or credit card number, the application 
>> has to send the page that requests it via a secure link. 
>> Unfortunately, that isn't possible in the literal sense. The 
>> application can't switch to SSL, the browser has to. That means that 
>> the page that displays the form must be requested by a page that 
>> knows the form needs to be sent securely. We've now had to back up by 
>> one full request/response cycle. Instead of the form transmission 
>> being secure (which it still has to be), the request for the page 
>> containing the form has to specify HTTPS, and the application then 
>> must send a form that also specifies HTTPS, or at least uses a 
>> relative url so it continues to use HTTPS.
>>
>> Because of all this, data transmission security must be handled by 
>> the view layer, because that's the part of  MVC model that generates 
>> the component that requests the form that must be secure. In a word: 
>> YUK. It's no real wonder that this doesn't fit cleanly into anyone's 
>> model. Even struts, which lives at the request/response level, 
>> doesn't handle this, you need the SSLEXT extension.
>>
>> In effect, however, what we are doing is specifying a property of the 
>> data transmission. And because the browser, and not the app, is in 
>> control, we have to tell the browser, in the iteration before the 
>> transmission in question, just what it needs to ask us to do.
>>
>> PRAGMATIC
>>
>> Because of all this, I think F. Da Costa's mechanism is the proper 
>> one, though we might all wish that weren't the case. In Tapestry 
>> terms, some component must request that the transmission be secure, 
>> because that's really the only place it can be done (assuming that a: 
>> we don't want to use HTTPS unless we have to because of the expense, 
>> and b: we only have to in certain limited circumstances). For the 
>> user to be happy about it, this has to happen a page sooner than 
>> strictly required (though it might be required that soon if the 
>> secure form will be preloaded with sensitive data, since the request 
>> must be secure before the response can be). These components can hack 
>> the link to make this happen.
>>
>> This leads me to a question, however. As I understand it, Tapestry 
>> will preserve the port and scheme from the request in generated URL's 
>> on the rendered page. So, how do we get OUT of SSL? Once we have 
>> returned the secure data, if any, from the secure transmission, are 
>> all the links on that page going to use SSL, because they preserve 
>> the schema and port from the request? Or will those ALWAYS specify 
>> HTTP and port 80 unless we specifically use a secure component? The 
>> latter behavior, while more convenient in this case, would certainly 
>> make writing an app that runs on an alternate port a pain.
>>
>> If the scheme and port are preserved, it almost seems that we need 
>> subclasses of link and form components that specify several different 
>> security options, and we have to use them anywhere we might need to 
>> transition from one to the other. In otherwords, on the login 
>> succesful page, we need a link to the home page that very 
>> specifically turns off HTTPS by specifying http and port 80. And if 
>> you want a succesful login to go to the home page, every link and 
>> form on the home page has to do this. Theoretically, a large 
>> percentage of the links and forms in an application might need to 
>> specify the security. In fact, the SSLEXT structs extension does 
>> this, you can specify that security be turned on, off, or left 
>> however it is, and you pretty much use their tags instead of the 
>> struts version throughout your app. I suppose that's about the best 
>> fit you'll get in the struts model, but I think Tapestry can do better.
>>
>> PROPOSAL
>>
>> What we're specifying, conceptually, are data transmission 
>> properties. But because we can only specify these in the URL, it's 
>> more useful to think of them as URL properties. Security is the 
>> obvious one, however, in search of a contrived example, let's say a 
>> company had a standard whereby certain information could only be 
>> served via web applications that were accessed through a specific 
>> port that was blocked by the company's firewall, and applications 
>> were required to enforce this by only providing internal data to 
>> requests received on this port. These transmissions could be 
>> considered to have the property "internal", as opposed to secure. The 
>> solution in Tapestry would be identical in form to secure 
>> transmissions. Now let's further assume that someone might someday 
>> want to change just which port the internal data is served from. :)
>>
>> A somewhat less contrived example would be in tying into J2EE 
>> declarative security, which is URL based. While this is, strictly 
>> speaking, a property of the URL and not the data transmission, it 
>> still happens at the same place, the href or action attribute of the 
>> corresponding HTML element.
>>
>> A possible solution to this would be for the components that generate 
>> links and forms (the only chance we get to tell the browser how to 
>> talk back to us) would support the ability to set a connection 
>> property on that link. This could be an arbitrary value, though for 
>> convenience, the value "secure" could be predefined. We could then 
>> determine what this means at the application level, by defining a 
>> family of link renderers, corresponding to the different connection 
>> properties used in our application. (Hmm, see below for a better idea 
>> on that.)
>>
>> I don't know if at the bottom of it all there's one link rendering 
>> class that does all the work for the various rendering classes, but 
>> if so, that would simplify the implementation of this greatly, in 
>> that it would allow you to impose specific patterns on the generated 
>> URLS. A "secure" link would use a renderer that forced HTTPS and port 
>> 443. An "insecure" link would force hhtp and port 80. An "internal" 
>> link would use a renderer that forced an alternate port.
>>
>> And, for people using J2EE security, a "customer service" link could 
>> enforce a particular URL pattern defined to J2EE as requiring a 
>> particular security role. This case would require some "link 
>> de-hacking" in Tapestry to restore the link so that it could be 
>> handled properly. Or would it? I haven't read that chapter yet, 
>> perhaps everything Tapestry needs is in the request parameters, and 
>> as long as it gets to the Tapestry servlet, the path information 
>> doesn't matter?
>>
>> Of course, if Tapestry preserves path, scheme and port info, we need 
>> to revert any of these things back to the default scheme, path and 
>> port at the right time, so perhaps a different mechanism is needed to 
>> "revert" the link, rather than specifying "insecure" to turn off 
>> HTTPS, and "external" to turn off "internal", etc. (As a side 
>> benefit, this mechanism allows one to easily change what that default 
>> is.) Also, potentially, these could be stackable, where we could have 
>> both secure and internal separately specified, or have the role 
>> independent of the transmission security (though I think J2EE can 
>> specify this, but with what level of granularity, and how much XML?).
>>
>> With this mechanism in place, it wouldn't actually be too 
>> unreasonable for all links to be forced to "normal" unless otherwise 
>> specified, thus solving the "revert" problem. That's also a lot safer 
>> in that if the application flow changes, you can't flow into a page 
>> that thinks the page before it set the security so it doesn't have 
>> to. And of course, with the ability to specify what "normal" is, if 
>> you need the whole app to be SSL, you only have to say so once, in 
>> the default link properties.
>>
>> In the end, this amounts to the same thing as F. Da Costa's solution, 
>> in so far as the security aspect is concerned, but with a lot less 
>> coding required of the application programmer. However, the solutions 
>> I've seen mentioned for the J2EE security problem are completely 
>> different (and beyond my current understanding of the machinery under 
>> the hood). I don't know how it compares to those, but it seems to 
>> require less coding there as well. In either case, it provides a 
>> useful abstraction so people don't have to know enough about all 
>> these mechanisms to implement those components. That is, after all, 
>> what a framework is for, to worry about these sorts of things so that 
>> we don't have to, any more than letting the framework know what we 
>> require of it, something that Tapestry does exceedingly well in most 
>> areas.
>>
>> At the worst case, the most you'd need would be a custom link 
>> renderer to support properties that didn't already come defined. And 
>> one could easily see the standard renderer being extended to do this 
>> task based on declarative rules rather than having to code it, at 
>> least for more common situations. Forcing a scheme, port or path 
>> prefix  should be easily declared. And again, in the J2EE case, this 
>> would let you simply declare a path prefix for each role matching 
>> your J2EE security declarations, and then tagging your links and 
>> forms with the role required to access that functionality. That may 
>> break down with multiple permissible roles, but someone who has 
>> actually used, rather than merely read about, J2EE security would 
>> have to answer that.
>>
>> I'm going to stop here, as I don't really know Tapestry well enough 
>> yet to suggest specific mechanisms. If the idea has any merit, 
>> perhaps others will fill that in, or I can talk more about it after I 
>> learn a bit more. As F. Da Costa has proven, all this is doable with 
>> the facilities we already have, but having it built in would be very 
>> slick, IMHO.
>>
>> FOOTNOTE
>>
>> I actually identified Tapestry as the web application technology for 
>> a project over a year ago, and then got sidetracked from that project 
>> until now, but I have nearly a year and a half of mailing list 
>> messages on my machine and searchable. Now I'm trying to get up to 
>> speed quickly, and that message archive is proving invaluable. Kudos 
>> to Howard, and everyone in the Tapestry community for the quality of 
>> the model, the software, and the discussions surrounding it.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: data transmission security

Posted by F Da Costa Gomez <da...@gmail.com>.
Hi Terry,

Terry Poot wrote:
> I'm a newbie to Tapestry (still reading the book), but have read the 
> excellent conversation thread between Paul Ferraro and F. Da Costa 
> regarding SSL-enabling links and forms in Tapestry. (Incidentally, I 
> don't see the code from F. Da Costa on the list implementing secure link 
> and form components. Was it ever posted?)
>
I thought I did but no worries. Please find attached.
A small note though. As i'm *by no means* a developer i just tend to get 
things to work reasonably. Making it perfect? i'm more than happy to 
leave that into more capable hands ;-)
This is also the reason for the rather 'hardcoded' nature of the 
components, i just work with the 80-443 and 8080-8443 combinations. I 
guess one could use a property thing to make *both* the ports variable. 
If this is already in place i'v just missed it.

One additional comment: as you mention further down in your post i'm 
moving in and out of secure mode as i want by just using the proper 
link-thing. I.e. when on a secure page i just use the normal PageLink 
and i'm back in normal mode. A SecureForm on a normal page takes care of 
putting that particular form in secure mode (or so it should at least).

I'm not suggesting these components are great but at least they work 
just fine for me (incl golden lock etc). I'm not sure why the subject 
was never picked up or whether it will this time but if the components 
are usefull for you, great.

Cheers,
Fermin DCG

> I have some thoughts on this from a conceptual view, and a proposal for 
> Tapestry that might be considered for a future revision. I'm sorry for 
> the length of this, but I felt I needed the explanations for this to 
> make any sense. I hope I succeeded in that. :)
> 
> CONCEPTUAL
> 
> Application frameworks don't generally take HTTPS into account in their 
> design. I suspect the reason for this is that it simply doesn't fit 
> cleanly into the model, for several reasons.
> 
> 1. It is a property of the wire protocols, and nobody wants to work at 
> that level. Howard repeatedly makes the point in the book that Tapestry 
> is meant to get you to a higher level than working at the http response 
> request cycle, where all this stuff lives.
> 
> 2. Security is not properly a concern of the View component of the MVC 
> architecture. The J2EE model makes it one, because of its reliance on 
> URL's, but that model has other problems in any case (that would be a 
> separate diatribe). The security model of an application is just that: a 
> model concern. Implementing it would be a controller concern. The view 
> might render things differently because of the decisions made by the 
> controller as informed by the model, but it doesn't care why or how 
> those decisions were made, or that they are security related, nor should 
> it.
> 
> There are 2 additional complications that screw it all up even further: 
> user perception and browers-induced confusion. These are related. Users 
> think that pages are secure, not transmissions, because the browser 
> shows them a security icon for a page that they have received via HTTPS. 
> That does indeed mean the data was sent securely. However, if they don't 
> see that indicator (the ubiquitous golden lock icon) they won't believe 
> their data will be SENT securely, which of course it could be if the 
> page specifies the proper URL. The browsers contribute to this with the 
> infamous "some parts of this page are insecure" types of warnings, 
> enforcing the perception that the page they are looking at has to be 
> "secure" for their data to be protected.
> 
> Because of the user perception issue, in order for a user to be willing 
> to enter a password or credit card number, the application has to send 
> the page that requests it via a secure link. Unfortunately, that isn't 
> possible in the literal sense. The application can't switch to SSL, the 
> browser has to. That means that the page that displays the form must be 
> requested by a page that knows the form needs to be sent securely. We've 
> now had to back up by one full request/response cycle. Instead of the 
> form transmission being secure (which it still has to be), the request 
> for the page containing the form has to specify HTTPS, and the 
> application then must send a form that also specifies HTTPS, or at least 
> uses a relative url so it continues to use HTTPS.
> 
> Because of all this, data transmission security must be handled by the 
> view layer, because that's the part of  MVC model that generates the 
> component that requests the form that must be secure. In a word: YUK. 
> It's no real wonder that this doesn't fit cleanly into anyone's model. 
> Even struts, which lives at the request/response level, doesn't handle 
> this, you need the SSLEXT extension.
> 
> In effect, however, what we are doing is specifying a property of the 
> data transmission. And because the browser, and not the app, is in 
> control, we have to tell the browser, in the iteration before the 
> transmission in question, just what it needs to ask us to do.
> 
> PRAGMATIC
> 
> Because of all this, I think F. Da Costa's mechanism is the proper one, 
> though we might all wish that weren't the case. In Tapestry terms, some 
> component must request that the transmission be secure, because that's 
> really the only place it can be done (assuming that a: we don't want to 
> use HTTPS unless we have to because of the expense, and b: we only have 
> to in certain limited circumstances). For the user to be happy about it, 
> this has to happen a page sooner than strictly required (though it might 
> be required that soon if the secure form will be preloaded with 
> sensitive data, since the request must be secure before the response can 
> be). These components can hack the link to make this happen.
> 
> This leads me to a question, however. As I understand it, Tapestry will 
> preserve the port and scheme from the request in generated URL's on the 
> rendered page. So, how do we get OUT of SSL? Once we have returned the 
> secure data, if any, from the secure transmission, are all the links on 
> that page going to use SSL, because they preserve the schema and port 
> from the request? Or will those ALWAYS specify HTTP and port 80 unless 
> we specifically use a secure component? The latter behavior, while more 
> convenient in this case, would certainly make writing an app that runs 
> on an alternate port a pain.
> 
> If the scheme and port are preserved, it almost seems that we need 
> subclasses of link and form components that specify several different 
> security options, and we have to use them anywhere we might need to 
> transition from one to the other. In otherwords, on the login succesful 
> page, we need a link to the home page that very specifically turns off 
> HTTPS by specifying http and port 80. And if you want a succesful login 
> to go to the home page, every link and form on the home page has to do 
> this. Theoretically, a large percentage of the links and forms in an 
> application might need to specify the security. In fact, the SSLEXT 
> structs extension does this, you can specify that security be turned on, 
> off, or left however it is, and you pretty much use their tags instead 
> of the struts version throughout your app. I suppose that's about the 
> best fit you'll get in the struts model, but I think Tapestry can do 
> better.
> 
> PROPOSAL
> 
> What we're specifying, conceptually, are data transmission properties. 
> But because we can only specify these in the URL, it's more useful to 
> think of them as URL properties. Security is the obvious one, however, 
> in search of a contrived example, let's say a company had a standard 
> whereby certain information could only be served via web applications 
> that were accessed through a specific port that was blocked by the 
> company's firewall, and applications were required to enforce this by 
> only providing internal data to requests received on this port. These 
> transmissions could be considered to have the property "internal", as 
> opposed to secure. The solution in Tapestry would be identical in form 
> to secure transmissions. Now let's further assume that someone might 
> someday want to change just which port the internal data is served from. :)
> 
> A somewhat less contrived example would be in tying into J2EE 
> declarative security, which is URL based. While this is, strictly 
> speaking, a property of the URL and not the data transmission, it still 
> happens at the same place, the href or action attribute of the 
> corresponding HTML element.
> 
> A possible solution to this would be for the components that generate 
> links and forms (the only chance we get to tell the browser how to talk 
> back to us) would support the ability to set a connection property on 
> that link. This could be an arbitrary value, though for convenience, the 
> value "secure" could be predefined. We could then determine what this 
> means at the application level, by defining a family of link renderers, 
> corresponding to the different connection properties used in our 
> application. (Hmm, see below for a better idea on that.)
> 
> I don't know if at the bottom of it all there's one link rendering class 
> that does all the work for the various rendering classes, but if so, 
> that would simplify the implementation of this greatly, in that it would 
> allow you to impose specific patterns on the generated URLS. A "secure" 
> link would use a renderer that forced HTTPS and port 443. An "insecure" 
> link would force hhtp and port 80. An "internal" link would use a 
> renderer that forced an alternate port.
> 
> And, for people using J2EE security, a "customer service" link could 
> enforce a particular URL pattern defined to J2EE as requiring a 
> particular security role. This case would require some "link de-hacking" 
> in Tapestry to restore the link so that it could be handled properly. Or 
> would it? I haven't read that chapter yet, perhaps everything Tapestry 
> needs is in the request parameters, and as long as it gets to the 
> Tapestry servlet, the path information doesn't matter?
> 
> Of course, if Tapestry preserves path, scheme and port info, we need to 
> revert any of these things back to the default scheme, path and port at 
> the right time, so perhaps a different mechanism is needed to "revert" 
> the link, rather than specifying "insecure" to turn off HTTPS, and 
> "external" to turn off "internal", etc. (As a side benefit, this 
> mechanism allows one to easily change what that default is.) Also, 
> potentially, these could be stackable, where we could have both secure 
> and internal separately specified, or have the role independent of the 
> transmission security (though I think J2EE can specify this, but with 
> what level of granularity, and how much XML?).
> 
> With this mechanism in place, it wouldn't actually be too unreasonable 
> for all links to be forced to "normal" unless otherwise specified, thus 
> solving the "revert" problem. That's also a lot safer in that if the 
> application flow changes, you can't flow into a page that thinks the 
> page before it set the security so it doesn't have to. And of course, 
> with the ability to specify what "normal" is, if you need the whole app 
> to be SSL, you only have to say so once, in the default link properties.
> 
> In the end, this amounts to the same thing as F. Da Costa's solution, in 
> so far as the security aspect is concerned, but with a lot less coding 
> required of the application programmer. However, the solutions I've seen 
> mentioned for the J2EE security problem are completely different (and 
> beyond my current understanding of the machinery under the hood). I 
> don't know how it compares to those, but it seems to require less coding 
> there as well. In either case, it provides a useful abstraction so 
> people don't have to know enough about all these mechanisms to implement 
> those components. That is, after all, what a framework is for, to worry 
> about these sorts of things so that we don't have to, any more than 
> letting the framework know what we require of it, something that 
> Tapestry does exceedingly well in most areas.
> 
> At the worst case, the most you'd need would be a custom link renderer 
> to support properties that didn't already come defined. And one could 
> easily see the standard renderer being extended to do this task based on 
> declarative rules rather than having to code it, at least for more 
> common situations. Forcing a scheme, port or path prefix  should be 
> easily declared. And again, in the J2EE case, this would let you simply 
> declare a path prefix for each role matching your J2EE security 
> declarations, and then tagging your links and forms with the role 
> required to access that functionality. That may break down with multiple 
> permissible roles, but someone who has actually used, rather than merely 
> read about, J2EE security would have to answer that.
> 
> I'm going to stop here, as I don't really know Tapestry well enough yet 
> to suggest specific mechanisms. If the idea has any merit, perhaps 
> others will fill that in, or I can talk more about it after I learn a 
> bit more. As F. Da Costa has proven, all this is doable with the 
> facilities we already have, but having it built in would be very slick, 
> IMHO.
> 
> FOOTNOTE
> 
> I actually identified Tapestry as the web application technology for a 
> project over a year ago, and then got sidetracked from that project 
> until now, but I have nearly a year and a half of mailing list messages 
> on my machine and searchable. Now I'm trying to get up to speed quickly, 
> and that message archive is proving invaluable. Kudos to Howard, and 
> everyone in the Tapestry community for the quality of the model, the 
> software, and the discussions surrounding it.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>