Adding JWT auth.
This commit is contained in:
parent
aed1ea104b
commit
eb2e346332
|
@ -6,12 +6,14 @@ X.Y.Z Release notes
|
|||
|
||||
### Enhancements
|
||||
* Added property `Realm.isClosed` which indicates if a Realm instance is closed or not.
|
||||
* [Object Server] Added JWT authenfication (#1548).
|
||||
|
||||
### Bug fixes
|
||||
* None.
|
||||
|
||||
### Internal
|
||||
* None.
|
||||
* [Object Server] Updated to Realm Object Server v2.2.0 for testing.
|
||||
|
||||
|
||||
2.0.13 Release notes (2017-12-8)
|
||||
=============================================================
|
||||
|
|
|
@ -2,4 +2,4 @@ PACKAGE_NAME=realm-js
|
|||
VERSION=2.0.13
|
||||
REALM_CORE_VERSION=4.0.2
|
||||
REALM_SYNC_VERSION=2.1.8
|
||||
REALM_OBJECT_SERVER_VERSION=2.0.21
|
||||
REALM_OBJECT_SERVER_VERSION=2.2.0
|
||||
|
|
|
@ -269,8 +269,25 @@ const staticMethods = {
|
|||
return _authenticate(this, server, json, callback);
|
||||
},
|
||||
|
||||
_refreshAccessToken: refreshAccessToken
|
||||
};
|
||||
authenticate(server, provider, options) {
|
||||
checkTypes(arguments, ['string', 'string', 'object'])
|
||||
|
||||
switch (provider) {
|
||||
case 'jwt':
|
||||
case 'JWT':
|
||||
options.provider = 'jwt'
|
||||
break
|
||||
default:
|
||||
return Promise.reject(`${provider} is not supported.`)
|
||||
}
|
||||
|
||||
return _authenticate(this, server, options)
|
||||
},
|
||||
|
||||
|
||||
_refreshAccessToken: refreshAccessToken,
|
||||
};
|
||||
|
||||
|
||||
const instanceMethods = {
|
||||
openManagementRealm() {
|
||||
|
|
|
@ -174,6 +174,18 @@ module.exports = {
|
|||
});
|
||||
},
|
||||
|
||||
testAuthenticateInvalidProvider() {
|
||||
return Realm.Sync.User.authenticate('http://localhost:9080', 'FooBar', {})
|
||||
.then((user) => { Promise.reject() } )
|
||||
.catch((e) => { Promise.resolve() } )
|
||||
},
|
||||
|
||||
testAuthenticateJWT() {
|
||||
return Realm.Sync.User.authenticate('http://localhost:9080', 'jwt', { token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ' })
|
||||
.then((user) => { Promise.resolve() } )
|
||||
.catch((e) => { Promise.reject(e) } )
|
||||
},
|
||||
|
||||
testAll() {
|
||||
const all = Realm.Sync.User.all;
|
||||
TestCase.assertArrayLength(Object.keys(all), 0);
|
||||
|
|
Loading…
Reference in New Issue