Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Security Issue #117

Open
sourcec0de opened this issue Dec 11, 2013 · 0 comments
Open

Possible Security Issue #117

sourcec0de opened this issue Dec 11, 2013 · 0 comments

Comments

@sourcec0de
Copy link

So, consider a scenario where the server template has some logic like this

if user.isAdmin()
     h1 Welcome Back Admin
else
    h1 Hey, Your not an admin

asset-rack exposes this logic to the user.

If you use asset-rack to compile all your jade templates anyone can see the admin templates. Weather you put logic in your template or not its still a privacy issue. I don't want to render my admin templates to any unauthorized users.

So, could we implement the ability to add middleware to the requests before the asset is served so they can be protected by user sessions?

I would be happy to contribute to this if anyone else see's this as a useful feature.

It should be simple enough to follow standard middleware procedure.

new rack.JadeAsset({
    url: '/adminTemplates.js',
    dirname: rootPath + '/views/admin/templates',
    middleware: [function(req,res,next){
        if(isAuthorized) return next();
        res.status(401);
        res.send('unauthorized access');
    }]
})

Is there already a way of doing something similar from outside of asset-rack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant