@@ -329,150 +329,6 @@ Hawk client from authenticating the requests.You can read more about the why and
329
329
[ article] ( http://www.html5rocks.com/en/tutorials/cors/#toc-adding-cors-support-to-the-server )
330
330
331
331
332
- ## hapi Plugin
333
-
334
- ** hawk** includes an authentication plugin for ** hapi** which registers two authentication schemes.
335
-
336
- ### hawk Strategy
337
-
338
- The scheme supports payload authentication. The scheme requires the following options:
339
-
340
- - ` getCredentialsFunc ` - credential lookup function with the signature ` [async] function(id) ` where:
341
- - ` id ` - the Hawk credentials identifier.
342
- - _ throws_ an internal error.
343
- - _ returns_ ` { credentials } ` object where:
344
- - ` credentials ` a credentials object passed back to the application in ` request.auth.credentials ` . Set to be ` null ` or ` undefined ` to
345
- indicate unknown credentials (which is not considered an error state).
346
- - ` hawk ` - optional protocol options passed to ` Hawk.server.authenticate() ` .
347
-
348
- ``` js
349
- const Hapi = require (' @hapi/hapi' );
350
- const Hawk = require (' @hapi/hawk' );
351
-
352
- const credentials = {
353
- d74s3nz2873n: {
354
- key: ' werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn' ,
355
- algorithm: ' sha256'
356
- }
357
- };
358
-
359
- const getCredentialsFunc = function (id ) {
360
-
361
- return credentials[id];
362
- };
363
-
364
- const start = async () => {
365
-
366
- const server = Hapi .server ({ port: 4000 });
367
-
368
- await server .register (Hawk);
369
-
370
- server .auth .strategy (' default' , ' hawk' , { getCredentialsFunc });
371
- server .auth .default (' default' );
372
-
373
- server .route ({
374
- method: ' GET' ,
375
- path: ' /' ,
376
- handler : function (request , h ) {
377
-
378
- return ' welcome' ;
379
- }
380
- });
381
-
382
- await server .start ();
383
-
384
- console .log (' Server started listening on %s' , server .info .uri );
385
- };
386
-
387
- start ();
388
-
389
- // Ensure process exits on unhandled rejection
390
-
391
- process .on (' unhandledRejection' , (err ) => {
392
-
393
- throw err;
394
- });
395
-
396
- ```
397
-
398
- ### bewit Strategy
399
-
400
- The scheme can only be used with 'GET' requests and requires the following options:
401
-
402
- - ` getCredentialsFunc ` - credential lookup function with the signature ` async function(id) ` where:
403
- - ` id ` - the Hawk credentials identifier.
404
- - _ throws_ an internal error.
405
- - _ returns_ ` { credentials } ` object where:
406
- - ` credentials ` a credentials object passed back to the application in ` request.auth.credentials ` . Set to be ` null ` or ` undefined ` to
407
- indicate unknown credentials (which is not considered an error state).
408
- - ` hawk ` - optional protocol options passed to ` Hawk.server.authenticateBewit() ` .
409
-
410
- ``` js
411
- const Hapi = require (' @hapi/hapi' );
412
- const Hawk = require (' @hapi/hawk' );
413
-
414
- const credentials = {
415
- d74s3nz2873n: {
416
- key: ' werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn' ,
417
- algorithm: ' sha256'
418
- }
419
- };
420
-
421
- const getCredentialsFunc = function (id ) {
422
-
423
- return credentials[id];
424
- };
425
-
426
- const start = async () => {
427
-
428
- const server = Hapi .server ({ port: 4000 });
429
-
430
- await server .register (Hawk);
431
-
432
- server .auth .strategy (' default' , ' bewit' , { getCredentialsFunc });
433
- server .auth .default (' default' );
434
-
435
- server .route ({
436
- method: ' GET' ,
437
- path: ' /' ,
438
- handler : function (request , h ) {
439
-
440
- return ' welcome' ;
441
- }
442
- });
443
-
444
- await server .start ();
445
-
446
- console .log (' Server started listening on %s' , server .info .uri );
447
- };
448
-
449
- start ();
450
-
451
- // Ensure process exits on unhandled rejection
452
-
453
- process .on (' unhandledRejection' , (err ) => {
454
-
455
- throw err;
456
- });
457
- ```
458
-
459
- To send an authenticated Bewit request, the URI must contain the ` 'bewit' ` query parameter which can be generated using the Hawk module:
460
-
461
- ``` js
462
- const Hawk = require (' @hapi/hawk' );
463
-
464
- const credentials = {
465
- id: ' d74s3nz2873n' ,
466
- key: ' werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn' ,
467
- algorithm: ' sha256'
468
- };
469
-
470
- let uri = ' http://example.com:8080/endpoint' ;
471
- const bewit = Hawk .client .getBewit (uri, { credentials: credentials, ttlSec: 60 });
472
- uri += ' ?bewit=' + bewit;
473
- ```
474
-
475
-
476
332
# Single URI Authorization
477
333
478
334
There are cases in which limited and short-term access to a protected resource is granted to a third party which does not
3 commit comments
community-tc-integration[bot] commentedon Oct 22, 2020
Uh oh! Looks like an error! Details
Taskcluster-GitHub attempted to create a task for this event with the following scopes:
The expansion of these scopes is not sufficient to create the task, leading to the following:
Client ID static/taskcluster/github does not have sufficient scopes and is missing the following scopes:
This request requires the client to satisfy the following scope expression:
community-tc-integration[bot] commentedon Oct 22, 2020
Uh oh! Looks like an error! Details
Taskcluster-GitHub attempted to create a task for this event with the following scopes:
The expansion of these scopes is not sufficient to create the task, leading to the following:
Client ID static/taskcluster/github does not have sufficient scopes and is missing the following scopes:
This request requires the client to satisfy the following scope expression:
community-tc-integration[bot] commentedon Oct 22, 2020
Uh oh! Looks like an error! Details
Taskcluster-GitHub attempted to create a task for this event with the following scopes:
The expansion of these scopes is not sufficient to create the task, leading to the following:
Client ID static/taskcluster/github does not have sufficient scopes and is missing the following scopes:
This request requires the client to satisfy the following scope expression: