-
Notifications
You must be signed in to change notification settings - Fork 0
Client-Auth files #21
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * @fileoverview Adds authentication information to a request and validates | ||
| * client info. | ||
| */ | ||
|
|
||
| const OICCli = require('../init.js').OICCli; | ||
| const utf8 = require('utf8'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused constant. Please remove for now. |
||
| const base64url = require('base64url'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused constant. Please remove for now. |
||
|
|
||
| /** | ||
| * ClientAuthnMethod | ||
| * Basic Client Authentication Method class. | ||
| * @class | ||
| * @constructor | ||
| */ | ||
| class ClientAuthnMethod { | ||
| constructor() {} | ||
|
|
||
| construct(params) { | ||
| throw new Error('Unsupported Operation Exception'); | ||
| } | ||
| } | ||
|
|
||
| function validServiceContext(serviceContext, when) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name of this function and what it does is not really intuitive. At first I thought it will give a valid ServiceContext object, but when I looked at the code it's checking whether How about changing the name into something more meaningful? E.g. It also might make sense to move this function into the |
||
| let eta = serviceContext['client_secret_expires_at'] || 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to have |
||
| let now = when || Date.now(); | ||
| if (eta !== 0 && eta < now) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| module.exports.ClientAuthnMethod = ClientAuthnMethod; | ||
| module.exports.validServiceContext = validServiceContext; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| const assert = require('chai').assert; | ||
| const validServiceContext = require('../src/clientAuth/clientAuth').validServiceContext; | ||
|
|
||
| describe('Test valid client info', function() { | ||
| let now = 123456; | ||
|
|
||
| it('test valid client info works', function() { | ||
| assert.isTrue(validServiceContext({}, now)); | ||
| assert.isTrue( | ||
| validServiceContext({'client_id': 'test', 'client_secret': 'secret'}, now)); | ||
| assert.isTrue(validServiceContext({'client_secret_expires_at': 0}, now)); | ||
| assert.isTrue(validServiceContext({'client_secret_expires_at': 123460}, now)); | ||
| assert.isTrue(validServiceContext( | ||
| {'client_id': 'test', 'client_secret_expires_at': 123460}, now)); | ||
| assert.isFalse(validServiceContext({'client_secret_expires_at': 1}, now)); | ||
| assert.isFalse(validServiceContext( | ||
| {'client_id': 'test', 'client_secret_expires_at': 123455}, now)); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused constant. Please remove for now.