mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
Remove `next-auth` and implement our own Authorization/Authentication system from scratch.
## Server
- [x] tokens
- [x] function
- [x] encryption
- [x] AuthController
- [x] /api/auth/sign-in
- [x] /api/auth/sign-out
- [x] /api/auth/session
- [x] /api/auth/session (WE SUPPORT MULTI-ACCOUNT!)
- [x] OAuthPlugin
- [x] OAuthController
- [x] /oauth/login
- [x] /oauth/callback
- [x] Providers
- [x] Google
- [x] GitHub
## Client
- [x] useSession
- [x] cloudSignIn
- [x] cloudSignOut
## NOTE:
Tests will be adding in the future
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { registerStorageProvider } from '../../fundamentals/storage';
|
|
import { Plugin } from '../registry';
|
|
import { R2StorageProvider } from './providers/r2';
|
|
import { S3StorageProvider } from './providers/s3';
|
|
|
|
registerStorageProvider('cloudflare-r2', (config, bucket) => {
|
|
if (!config.plugins['cloudflare-r2']) {
|
|
throw new Error('Missing cloudflare-r2 storage provider configuration');
|
|
}
|
|
|
|
return new R2StorageProvider(config.plugins['cloudflare-r2'], bucket);
|
|
});
|
|
registerStorageProvider('aws-s3', (config, bucket) => {
|
|
if (!config.plugins['aws-s3']) {
|
|
throw new Error('Missing aws-s3 storage provider configuration');
|
|
}
|
|
|
|
return new S3StorageProvider(config.plugins['aws-s3'], bucket);
|
|
});
|
|
|
|
@Plugin({
|
|
name: 'cloudflare-r2',
|
|
requires: [
|
|
'plugins.cloudflare-r2.accountId',
|
|
'plugins.cloudflare-r2.credentials.accessKeyId',
|
|
'plugins.cloudflare-r2.credentials.secretAccessKey',
|
|
],
|
|
if: config => config.flavor.graphql,
|
|
})
|
|
export class CloudflareR2Module {}
|
|
|
|
@Plugin({
|
|
name: 'aws-s3',
|
|
requires: [
|
|
'plugins.aws-s3.credentials.accessKeyId',
|
|
'plugins.aws-s3.credentials.secretAccessKey',
|
|
],
|
|
if: config => config.flavor.graphql,
|
|
})
|
|
export class AwsS3Module {}
|
|
|
|
export type { R2StorageConfig, S3StorageConfig } from './types';
|