jeffpatterson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Dec-11 16:06 UTC
Validating a legal subdomain
I have a Rails app that uses subdomains as account keys. Users name their own subdomains. How can I validate those subdomains as legal? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 11 Dec 2008, at 17:06, jeffpatterson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I have a Rails app that uses subdomains as account keys. Users name > their own subdomains. How can I validate those subdomains as legal?Just like you would verify a user login. The subdomain then becomes part of the login procedure. You store it in a table and you "authenticate" the domain in a before_filter. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think what Jeff meant is how to validate the subdomain as a normal combination of letters and integers without a bunch of strange keys. He''s not talking about authentication, he''s talking about validation. I''ll post here if I get this going Jeff. I''m also working on a way. It looks like it will have to be a regular expression. On Dec 12 2008, 12:33 am, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote:> On 11 Dec 2008, at 17:06, jeffpatter...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > I have a Rails app that uses subdomains as account keys. Users name > > their own subdomains. How can I validate those subdomains as legal? > > Just like you would verify a user login. The subdomain then becomes > part of the login procedure. You store it in a table and you > "authenticate" the domain in a before_filter. > > Best regards > > Peter De Berdt--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I eventually settled on a regex that permits only letters, numbers and hyphens. Close enough for my needs: validates_format_of :subdomain, :with => /^[a-zA-Z0-9\-]*?$/, :message => ''accepts only letters, numbers and hyphens'' Hope that''s helpful! Jeff On Jan 8, 5:10 pm, scottmotte <sc...-+TjdMNlRbEVGBRGhe+f61g@public.gmane.org> wrote:> I think what Jeff meant is how to validate the subdomain as a normal > combination of letters and integers without a bunch of strange keys. > He''s not talking about authentication, he''s talking about validation. > > I''ll post here if I get this going Jeff. I''m also working on a way. It > looks like it will have to be a regular expression. > > On Dec 12 2008, 12:33 am, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> > wrote: > > > On 11 Dec 2008, at 17:06, jeffpatter...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > I have a Rails app that uses subdomains as account keys. Users name > > > their own subdomains. How can I validate those subdomains as legal? > > > Just like you would verify a user login. The subdomain then becomes > > part of the login procedure. You store it in a table and you > > "authenticate" the domain in a before_filter. > > > Best regards > > > Peter De Berdt--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That is pretty much what I was going to recommend. On Jan 8, 9:40 pm, Jeff <jeffpatter...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I eventually settled on a regex that permits only letters, numbers and > hyphens. Close enough for my needs: > > validates_format_of :subdomain, > :with => /^[a-zA-Z0-9\-]*?$/, > :message => ''accepts only letters, numbers > and hyphens'' > > Hope that''s helpful! > > Jeff > > On Jan 8, 5:10 pm, scottmotte <sc...-+TjdMNlRbEVGBRGhe+f61g@public.gmane.org> wrote: > > > I think what Jeff meant is how to validate the subdomain as a normal > > combination of letters and integers without a bunch of strange keys. > > He''s not talking about authentication, he''s talking about validation. > > > I''ll post here if I get this going Jeff. I''m also working on a way. It > > looks like it will have to be a regular expression. > > > On Dec 12 2008, 12:33 am, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> > > wrote: > > > > On 11 Dec 2008, at 17:06, jeffpatter...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > I have a Rails app that uses subdomains as account keys. Users name > > > > their own subdomains. How can I validate those subdomains as legal? > > > > Just like you would verify a user login. The subdomain then becomes > > > part of the login procedure. You store it in a table and you > > > "authenticate" the domain in a before_filter. > > > > Best regards > > > > Peter De Berdt > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Jeff. =) On Jan 8, 7:40 pm, Jeff <jeffpatter...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I eventually settled on a regex that permits only letters, numbers and > hyphens. Close enough for my needs: > > validates_format_of :subdomain, > :with => /^[a-zA-Z0-9\-]*?$/, > :message => ''accepts only letters, numbers > and hyphens'' > > Hope that''s helpful! > > Jeff > > On Jan 8, 5:10 pm, scottmotte <sc...-+TjdMNlRbEVGBRGhe+f61g@public.gmane.org> wrote: > > > I think what Jeff meant is how to validate the subdomain as a normal > > combination of letters and integers without a bunch of strange keys. > > He''s not talking about authentication, he''s talking about validation. > > > I''ll post here if I get this going Jeff. I''m also working on a way. It > > looks like it will have to be a regular expression. > > > On Dec 12 2008, 12:33 am, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> > > wrote: > > > > On 11 Dec 2008, at 17:06, jeffpatter...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > I have a Rails app that uses subdomains as account keys. Users name > > > > their own subdomains. How can I validate those subdomains as legal? > > > > Just like you would verify a user login. The subdomain then becomes > > > part of the login procedure. You store it in a table and you > > > "authenticate" the domain in a before_filter. > > > > Best regards > > > > Peter De Berdt > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---