File tree Expand file tree Collapse file tree
resources/acl/fake-account Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ var argv = require('nomnom')
5353 help : 'HTTP Session secret key (e.g. "your secret phrase")' ,
5454 abbr : 's'
5555 } )
56+ . option ( 'forceUser' , {
57+ help : 'Force a WebID to always be logged in (usefull when offline)' ,
58+ abbr : 'fU' ,
59+ full : 'force-user'
60+ } )
5661 . option ( 'proxy' , {
5762 full : 'proxy' ,
5863 help : 'Use a proxy on example.tld/proxyPath' ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ function LDP(argv) {
1919 argv = argv || { } ;
2020 var ldp = this ;
2121 // From input
22+ ldp . forceUser = argv . forceUser ;
2223 ldp . cache = argv . cache ;
2324 ldp . live = argv . live ;
2425 ldp . root = argv . root || process . cwd ( ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ var HttpError = require('./http-error');
77function loginHandler ( req , res , next ) {
88 var ldp = req . app . locals . ldp ;
99
10+ if ( ldp . forceUser ) {
11+ req . session . userId = ldp . forceUser ;
12+ req . session . identified = true ;
13+ debug ( "Identified user: " + req . session . userId ) ;
14+ res . set ( 'User' , req . session . userId ) ;
15+ return next ( ) ;
16+ }
17+
1018 // No webid required? skip
1119 if ( ! ldp . webid ) {
1220 setEmptySession ( req ) ;
Original file line number Diff line number Diff line change @@ -179,4 +179,34 @@ describe('LDNODE params', function () {
179179 } ) ;
180180 } ) ;
181181 } ) ;
182+
183+ describe ( 'forcedUser' , function ( ) {
184+
185+ var ldpHttpsServer
186+ var ldp = ldnode . createServer ( {
187+ forceUser : 'https://fakeaccount.com/profile#me' ,
188+ root : __dirname + '/resources/acl/fake-account' ,
189+ key : __dirname + '/keys/key.pem' ,
190+ cert : __dirname + '/keys/cert.pem' ,
191+ webid : true ,
192+ host : 'localhost:3457'
193+ } )
194+
195+ var ldpHttpsServer
196+ before ( function ( done ) {
197+ ldpHttpsServer = ldp . listen ( 3459 , done )
198+ } )
199+
200+ after ( function ( ) {
201+ if ( ldpHttpsServer ) ldpHttpsServer . close ( )
202+ } )
203+
204+ var server = supertest ( 'https://localhost:3459' )
205+
206+ it ( 'should find resource in correct path' , function ( done ) {
207+ server . get ( '/hello.html' )
208+ . expect ( 'User' , 'https://fakeaccount.com/profile#me' )
209+ . end ( done ) ;
210+ } ) ;
211+ } ) ;
182212} ) ;
Original file line number Diff line number Diff line change 1+ <#0>
2+ <http://www.w3.org/ns/auth/acl#defaultForNew> <./> ;
3+ <http://www.w3.org/ns/auth/acl#agent> <https://fakeaccount.com/profile#me> ;
4+ <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Control>.
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < title > Hello</ title >
5+ </ head >
6+ < body >
7+ Hello
8+ </ body >
9+ </ html >
You can’t perform that action at this time.
0 commit comments