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

feat: Improve authentication adapter interface #8156

Merged
merged 50 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
57ac3fd
feat: new auth adapter interface
Moumouls Jun 6, 2022
5b2e0b3
Merge branch 'community-alpha' into moumouls/webauthn-adapter
Moumouls Jun 6, 2022
cf4a527
fix: feedbacks
Moumouls Jun 6, 2022
5dbee87
fix: restore lock
Moumouls Jun 6, 2022
28636ce
Apply suggestions from code review
Moumouls Jun 8, 2022
ec1d61e
Update src/Adapters/Auth/index.js
mtrezza Jun 8, 2022
adfacc2
Apply suggestions from code review
Moumouls Jun 10, 2022
ca92650
Update src/Adapters/Auth/AuthAdapter.js
Moumouls Jun 10, 2022
7cafead
Update src/Adapters/Auth/AuthAdapter.js
Moumouls Jun 10, 2022
3131e65
Update src/Adapters/Auth/AuthAdapter.js
Moumouls Jun 10, 2022
71d2374
Update src/Adapters/Auth/AuthAdapter.js
Moumouls Jun 10, 2022
fd5a7fd
Update src/Adapters/Auth/AuthAdapter.js
Moumouls Jun 10, 2022
1beebdc
fix: bracket
Moumouls Jun 10, 2022
d12811d
Merge branch 'alpha' into moumouls/webauthn-adapter
Moumouls Jun 12, 2022
4e20959
fix: js doc on isChallenge
Moumouls Jun 14, 2022
80652f5
Merge branch 'alpha' into moumouls/webauthn-adapter
Moumouls Jun 14, 2022
731486d
Merge branch 'alpha' into moumouls/webauthn-adapter
Moumouls Jun 20, 2022
9900c64
fix: login with mutated authData and doNotSave true
Moumouls Jun 21, 2022
3b473f8
Merge branch 'alpha' into moumouls/webauthn-adapter
mtrezza Jun 24, 2022
814ba6c
Merge branch 'alpha' into moumouls/webauthn-adapter
mtrezza Jul 2, 2022
f6bf6a1
Update src/Routers/UsersRouter.js
mtrezza Jul 2, 2022
0cace74
Update src/Routers/UsersRouter.js
mtrezza Jul 2, 2022
b8a6fc9
Merge branch 'alpha' into moumouls/webauthn-adapter
Moumouls Jul 3, 2022
57026b2
fix: test
Moumouls Jul 3, 2022
7353012
feat: add validation on policy
Moumouls Jul 3, 2022
7dd7d2f
Merge branch 'alpha' into moumouls/webauthn-adapter
Moumouls Jul 3, 2022
1d8a4d8
Merge branch 'alpha' into moumouls/webauthn-adapter
mtrezza Jul 20, 2022
de2e08a
Merge branch 'alpha' into moumouls/webauthn-adapter
mtrezza Jul 28, 2022
713aa5d
Merge branch 'alpha' into moumouls/webauthn-adapter
mtrezza Aug 16, 2022
bc0e38c
Merge branch 'alpha' into moumouls/webauthn-adapter
mtrezza Aug 31, 2022
b3bb21f
feat: new auth adapter (continuation)
dblythy Sep 8, 2022
6d1126a
Update AuthenticationAdaptersV2.spec.js
dblythy Sep 8, 2022
68c22ae
Merge branch 'alpha' into new-auth-adapter
dblythy Sep 8, 2022
63e00d5
fix tests
dblythy Sep 8, 2022
6eba4ff
Merge branch 'alpha' into new-auth-adapter
mtrezza Sep 8, 2022
d152eee
Merge branch 'alpha' into new-auth-adapter
mtrezza Sep 12, 2022
3b20b19
Merge branch 'alpha' into new-auth-adapter
mtrezza Sep 20, 2022
2a1b0a6
Merge branch 'alpha' into new-auth-adapter
mtrezza Sep 21, 2022
4d1f1fe
Merge branch 'alpha' into new-auth-adapter
dblythy Oct 15, 2022
3fd6732
Merge branch 'alpha' into new-auth-adapter
dblythy Nov 1, 2022
2534870
revert options
dblythy Nov 1, 2022
11b1454
fix null bug
dblythy Nov 1, 2022
f9b78ab
Merge branch 'new-auth-adapter' of https://github.com/dblythy/parse-s…
dblythy Nov 1, 2022
cc81c1d
Merge branch 'alpha' into new-auth-adapter
mtrezza Nov 1, 2022
741e406
Update ParseGraphQLServer.spec.js
dblythy Nov 2, 2022
d76c2af
Merge branch 'alpha' into new-auth-adapter
mtrezza Nov 3, 2022
98000c7
Update src/Options/index.js
dblythy Nov 3, 2022
b58d6a0
definitions
dblythy Nov 3, 2022
571efb3
fix deprecation description
mtrezza Nov 3, 2022
838cf17
Merge branch 'alpha' into new-auth-adapter
mtrezza Nov 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following is a list of deprecations, according to the [Deprecation Policy](h
| DEPPS5 | Config option `allowClientClassCreation` defaults to `false` | [#7925](https://github.com/parse-community/parse-server/pull/7925) | 5.3.0 (2022) | 7.0.0 (2024) | deprecated | - |
| DEPPS6 | Auth providers disabled by default | [#7953](https://github.com/parse-community/parse-server/pull/7953) | 5.3.0 (2022) | 7.0.0 (2024) | deprecated | - |
| DEPPS7 | Remove file trigger syntax `Parse.Cloud.beforeSaveFile((request) => {})` | [#7966](https://github.com/parse-community/parse-server/pull/7966) | 5.3.0 (2022) | 7.0.0 (2024) | deprecated | - |
| DEPPS8 | Allow login with expired authData token | [#7079](https://github.com/parse-community/parse-server/pull/7079) | 5.3.0 (2022) | 7.0.0 (2024) | deprecated | - |
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
mtrezza marked this conversation as resolved.
Show resolved Hide resolved

[i_deprecation]: ## "The version and date of the deprecation."
[i_removal]: ## "The version and date of the planned removal."
Expand Down
73 changes: 62 additions & 11 deletions spec/AuthenticationAdapters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,49 @@ describe('AuthenticationProviders', function () {
.catch(done.fail);
});

it('should support loginWith with session token and with/without mutated authData', async () => {
const fakeAuthProvider = {
validateAppId: () => Promise.resolve(),
validateAuthData: () => Promise.resolve(),
};
const payload = { authData: { id: 'user1', token: 'fakeToken' } };
const payload2 = { authData: { id: 'user1', token: 'fakeToken2' } };
await reconfigureServer({ auth: { fakeAuthProvider } });
const user = await Parse.User.logInWith('fakeAuthProvider', payload);
const user2 = await Parse.User.logInWith('fakeAuthProvider', payload, {
sessionToken: user.getSessionToken(),
});
const user3 = await Parse.User.logInWith('fakeAuthProvider', payload2, {
sessionToken: user2.getSessionToken(),
});
expect(user.id).toEqual(user2.id);
expect(user.id).toEqual(user3.id);
});

it('should support sync/async validateAppId', async () => {
const syncProvider = {
validateAppId: () => true,
appIds: 'test',
validateAuthData: () => Promise.resolve(),
};
const asyncProvider = {
appIds: 'test',
validateAppId: () => Promise.resolve(true),
validateAuthData: () => Promise.resolve(),
};
const payload = { authData: { id: 'user1', token: 'fakeToken' } };
const syncSpy = spyOn(syncProvider, 'validateAppId');
const asyncSpy = spyOn(asyncProvider, 'validateAppId');

await reconfigureServer({ auth: { asyncProvider, syncProvider } });
const user = await Parse.User.logInWith('asyncProvider', payload);
const user2 = await Parse.User.logInWith('syncProvider', payload);
expect(user.getSessionToken()).toBeDefined();
expect(user2.getSessionToken()).toBeDefined();
expect(syncSpy).toHaveBeenCalledTimes(1);
expect(asyncSpy).toHaveBeenCalledTimes(1);
});

it('unlink and link with custom provider', async () => {
const provider = getMockMyOauthProvider();
Parse.User._registerAuthenticationProvider(provider);
Expand Down Expand Up @@ -339,10 +382,10 @@ describe('AuthenticationProviders', function () {
});

validateAuthenticationHandler(authenticationHandler);
const validator = authenticationHandler.getValidatorForProvider('customAuthentication');
const { validator } = authenticationHandler.getValidatorForProvider('customAuthentication');
validateValidator(validator);

validator(validAuthData).then(
validator(validAuthData, {}, {}).then(
() => {
expect(authDataSpy).toHaveBeenCalled();
// AppIds are not provided in the adapter, should not be called
Expand All @@ -362,12 +405,15 @@ describe('AuthenticationProviders', function () {
});

validateAuthenticationHandler(authenticationHandler);
const validator = authenticationHandler.getValidatorForProvider('customAuthentication');
const { validator } = authenticationHandler.getValidatorForProvider('customAuthentication');
validateValidator(validator);

validator({
token: 'my-token',
}).then(
validator(
{
token: 'my-token',
},
{},
{}
).then(
() => {
done();
},
Expand All @@ -387,12 +433,16 @@ describe('AuthenticationProviders', function () {
});

validateAuthenticationHandler(authenticationHandler);
const validator = authenticationHandler.getValidatorForProvider('customAuthentication');
const { validator } = authenticationHandler.getValidatorForProvider('customAuthentication');
validateValidator(validator);

validator({
token: 'valid-token',
}).then(
validator(
{
token: 'valid-token',
},
{},
{}
).then(
() => {
done();
},
Expand Down Expand Up @@ -541,6 +591,7 @@ describe('AuthenticationProviders', function () {
});

it('can depreciate', async () => {
await reconfigureServer();
const Deprecator = require('../lib/Deprecator/Deprecator');
const spy = spyOn(Deprecator, 'logRuntimeDeprecation').and.callFake(() => {});
const provider = getMockMyOauthProvider();
Expand Down
Loading