Compare commits

..

8 Commits

Author SHA1 Message Date
standardci
7e989720bf chore(release): publish new version
- @standardnotes/auth-server@1.93.12
2023-03-16 13:31:44 +00:00
Karol Sójko
f8a2892811 fix(auth): persistence mapping for authenticators 2023-03-16 14:14:46 +01:00
Karol Sójko
eaab23ec19 fix: persistent server keys between updates - fixes #476 (#481)
* fix: persistent server keys between updates - fixes #476

* fix: env vars for ci
2023-03-16 11:02:16 +01:00
standardci
36dcdf256f chore(release): publish new version
- @standardnotes/revisions-server@1.12.11
 - @standardnotes/syncing-server@1.32.4
2023-03-15 10:36:43 +00:00
Karol Sójko
10a596db65 fix(syncing-server): remove unused methods from auth http service 2023-03-15 11:20:24 +01:00
Karol Sójko
c76302cf98 fix(revisions): add warning logs if a revision dump could not be found 2023-03-15 11:14:48 +01:00
standardci
176cf608ef chore(release): publish new version
- @standardnotes/auth-server@1.93.11
2023-03-10 14:12:51 +00:00
Karol Sójko
f69073ba02 fix(auth): chage attestation type to none 2023-03-10 14:59:14 +01:00
17 changed files with 69 additions and 75 deletions

View File

@@ -7,7 +7,6 @@ DB_PORT=3306
DB_USERNAME=std_notes_user
DB_PASSWORD=changeme123
DB_DATABASE=standard_notes_db
DB_DEBUG_LEVEL=all
#########
# CACHE #
@@ -15,3 +14,11 @@ DB_DEBUG_LEVEL=all
REDIS_PORT=6379
REDIS_HOST=cache
########
# KEYS #
########
AUTH_JWT_SECRET=
AUTH_SERVER_ENCRYPTION_SERVER_KEY=
VALET_TOKEN_SECRET=

5
.github/ci.env vendored
View File

@@ -3,6 +3,7 @@ DB_HOST=db
DB_USERNAME=std_notes_user
DB_PASSWORD=changeme123
DB_DATABASE=standard_notes_db
DB_PORT=3306
REDIS_PORT=6379
REDIS_HOST=cache
AUTH_SERVER_ACCESS_TOKEN_AGE=4
@@ -19,3 +20,7 @@ MYSQL_DATABASE=standard_notes_db
MYSQL_USER=std_notes_user
MYSQL_PASSWORD=changeme123
MYSQL_ROOT_PASSWORD=changeme123
AUTH_JWT_SECRET=f95259c5e441f5a4646d76422cfb3df4c4488842901aa50b6c51b8be2e0040e9
AUTH_SERVER_ENCRYPTION_SERVER_KEY=1087415dfde3093797f9a7ca93a49e7d7aa1861735eb0d32aae9c303b8c3d060
VALET_TOKEN_SECRET=4b886819ebe1e908077c6cae96311b48a8416bd60cc91c03060e15bdf6b30d1f

View File

@@ -27,19 +27,24 @@ fi
######
if [ -z "$DB_HOST" ]; then
export DB_HOST="db"
echo "DB_HOST is not set. Please set it in your .env file."
exit 1
fi
if [ -z "$DB_PORT" ]; then
export DB_PORT="3306"
echo "DB_PORT is not set. Please set it in your .env file."
exit 1
fi
if [ -z "$DB_USERNAME" ]; then
export DB_USERNAME="std_notes_user"
echo "DB_USERNAME is not set. Please set it in your .env file."
exit 1
fi
if [ -z "$DB_PASSWORD" ]; then
export DB_PASSWORD=$(openssl rand -hex 32)
echo "DB_PASSWORD is not set. Please set it in your .env file."
exit 1
fi
if [ -z "$DB_DATABASE" ]; then
export DB_DATABASE="standard_notes_db"
echo "DB_DATABASE is not set. Please set it in your .env file."
exit 1
fi
if [ -z "$DB_DEBUG_LEVEL" ]; then
export DB_DEBUG_LEVEL="all"
@@ -51,11 +56,13 @@ export DB_MIGRATIONS_PATH="dist/migrations/*.js"
#########
if [ -z "$REDIS_PORT" ]; then
export REDIS_PORT=6379
echo "REDIS_PORT is not set. Please set it in your .env file."
exit 1
fi
if [ -z "$REDIS_HOST" ]; then
export REDIS_HOST="cache"
echo "REDIS_HOST is not set. Please set it in your .env file."
exit 1
fi
if [ -z "$REDIS_URL" ]; then
@@ -67,11 +74,13 @@ fi
##########
if [ -z "$AUTH_JWT_SECRET" ]; then
export AUTH_JWT_SECRET=$(openssl rand -hex 32)
echo "AUTH_JWT_SECRET is not set. Please set it in your .env file. You can run 'openssl rand -hex 32' to generate a random string."
exit 1
fi
if [ -z "$VALET_TOKEN_SECRET" ]; then
export VALET_TOKEN_SECRET=$(openssl rand -base64 32)
echo "VALET_TOKEN_SECRET is not set. Please set it in your .env file. You can run 'openssl rand -hex 32' to generate a random string."
exit 1
fi
########
@@ -122,7 +131,8 @@ if [ -z "$AUTH_SERVER_EPHEMERAL_SESSION_AGE" ]; then
fi
if [ -z "$AUTH_SERVER_ENCRYPTION_SERVER_KEY" ]; then
export AUTH_SERVER_ENCRYPTION_SERVER_KEY=$(openssl rand -hex 32)
echo "AUTH_SERVER_ENCRYPTION_SERVER_KEY is not set. Please set it in your .env file. You can run 'openssl rand -hex 32' to generate a random string."
exit 1
fi
export AUTH_SERVER_SYNCING_SERVER_URL=http://localhost:$SYNCING_SERVER_PORT

View File

@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.93.12](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.93.11...@standardnotes/auth-server@1.93.12) (2023-03-16)
### Bug Fixes
* **auth:** persistence mapping for authenticators ([f8a2892](https://github.com/standardnotes/server/commit/f8a2892811ebb4d8f067e036fb9f54780a400535))
## [1.93.11](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.93.10...@standardnotes/auth-server@1.93.11) (2023-03-10)
### Bug Fixes
* **auth:** chage attestation type to none ([f69073b](https://github.com/standardnotes/server/commit/f69073ba029bfe15cb6855ff764aba96010c84da))
## [1.93.10](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.93.9...@standardnotes/auth-server@1.93.10) (2023-03-10)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.93.10",
"version": "1.93.12",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -33,7 +33,7 @@ export class GenerateAuthenticatorRegistrationOptions implements UseCaseInterfac
rpName: this.relyingPartyName,
userID: userUuid.value,
userName: username.value,
attestationType: 'direct',
attestationType: 'none',
authenticatorSelection: {
authenticatorAttachment: 'cross-platform',
},

View File

@@ -23,8 +23,8 @@ export class AuthenticatorPersistenceMapper implements MapperInterface<Authentic
counter: projection.counter,
credentialBackedUp: projection.credentialBackedUp,
credentialDeviceType: projection.credentialDeviceType,
credentialId: Buffer.from(projection.credentialId, 'base64url'),
credentialPublicKey: projection.credentialPublicKey,
credentialId: new Uint8Array(Buffer.from(projection.credentialId, 'base64url')),
credentialPublicKey: new Uint8Array(projection.credentialPublicKey),
dates,
transports: projection.transports ? JSON.parse(projection.transports) : undefined,
},
@@ -43,7 +43,7 @@ export class AuthenticatorPersistenceMapper implements MapperInterface<Authentic
typeorm.uuid = domain.id.toString()
typeorm.userUuid = domain.props.userUuid.value
typeorm.credentialId = Buffer.from(domain.props.credentialId).toString('base64url')
typeorm.credentialId = Buffer.from(domain.props.credentialId.buffer).toString('base64url')
typeorm.credentialPublicKey = Buffer.from(domain.props.credentialPublicKey.buffer)
typeorm.counter = domain.props.counter
typeorm.credentialDeviceType = domain.props.credentialDeviceType

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.12.11](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.12.10...@standardnotes/revisions-server@1.12.11) (2023-03-15)
### Bug Fixes
* **revisions:** add warning logs if a revision dump could not be found ([c76302c](https://github.com/standardnotes/server/commit/c76302cf9868f59770bde3882dcac67f4c51314b))
## [1.12.10](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.12.9...@standardnotes/revisions-server@1.12.10) (2023-03-10)
**Note:** Version bump only for package @standardnotes/revisions-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.12.10",
"version": "1.12.11",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -83,6 +83,7 @@ export class WorkerContainerConfigLoader extends CommonContainerConfigLoader {
context.container.get(TYPES.S3_BACKUP_BUCKET_NAME),
context.container.get(TYPES.S3),
context.container.get(TYPES.RevisionItemStringMapper),
context.container.get(TYPES.Logger),
)
} else {
return new FSDumpRepository(context.container.get(TYPES.RevisionItemStringMapper))

View File

@@ -1,5 +1,6 @@
import { DeleteObjectCommand, GetObjectCommand, S3Client } from '@aws-sdk/client-s3'
import { MapperInterface } from '@standardnotes/domain-core'
import { Logger } from 'winston'
import { DumpRepositoryInterface } from '../../Domain/Dump/DumpRepositoryInterface'
import { Revision } from '../../Domain/Revision/Revision'
@@ -9,6 +10,7 @@ export class S3DumpRepository implements DumpRepositoryInterface {
private dumpBucketName: string,
private s3Client: S3Client,
private revisionStringItemMapper: MapperInterface<Revision, string>,
private logger: Logger,
) {}
async getRevisionFromDumpPath(path: string): Promise<Revision | null> {
@@ -20,6 +22,8 @@ export class S3DumpRepository implements DumpRepositoryInterface {
)
if (s3Object.Body === undefined) {
this.logger.warn(`Could not find revision dump at path: ${path}`)
return null
}

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.32.4](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.32.3...@standardnotes/syncing-server@1.32.4) (2023-03-15)
### Bug Fixes
* **syncing-server:** remove unused methods from auth http service ([10a596d](https://github.com/standardnotes/syncing-server-js/commit/10a596db655dc27f4acfef203c38362fb779cc25))
## [1.32.3](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.32.2...@standardnotes/syncing-server@1.32.3) (2023-03-10)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.32.3",
"version": "1.32.4",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -2,5 +2,4 @@ import { KeyParamsData } from '@standardnotes/responses'
export interface AuthHttpServiceInterface {
getUserKeyParams(dto: { email?: string; uuid?: string; authenticated: boolean }): Promise<KeyParamsData>
getUserSetting(userUuid: string, settingName: string): Promise<{ uuid: string; value: string | null }>
}

View File

@@ -37,7 +37,6 @@ describe('CloudBackupRequestedEventHandler', () => {
authHttpService = {} as jest.Mocked<AuthHttpServiceInterface>
authHttpService.getUserKeyParams = jest.fn().mockReturnValue({ foo: 'bar' })
// authHttpService.getUserSetting = jest.fn().mockReturnValue
extensionsHttpService = {} as jest.Mocked<ExtensionsHttpServiceInterface>
extensionsHttpService.triggerCloudBackupOnExtensionsServer = jest.fn()

View File

@@ -3,7 +3,6 @@ import 'reflect-metadata'
import { AxiosInstance } from 'axios'
import { AuthHttpService } from './AuthHttpService'
import { SettingName } from '@standardnotes/settings'
describe('AuthHttpService', () => {
let httpClient: AxiosInstance
@@ -36,39 +35,4 @@ describe('AuthHttpService', () => {
validateStatus: expect.any(Function),
})
})
it('should send a request to auth service in order to get user setting', async () => {
httpClient.request = jest.fn().mockReturnValue({
data: {
setting: [
{
uuid: '1-2-3',
value: 'yes',
},
],
},
})
await createService().getUserSetting('1-2-3', SettingName.NAMES.MuteFailedBackupsEmails)
expect(httpClient.request).toHaveBeenCalledWith({
method: 'GET',
headers: {
Accept: 'application/json',
},
url: 'https://auth-server/internal/users/1-2-3/settings/MUTE_FAILED_BACKUPS_EMAILS',
validateStatus: expect.any(Function),
})
})
it('should throw an error if a request to auth service in order to get user setting fails', async () => {
let error = null
try {
await createService().getUserSetting('1-2-3', SettingName.NAMES.MuteFailedCloudBackupsEmails)
} catch (caughtError) {
error = caughtError
}
expect(error).not.toBeNull()
})
})

View File

@@ -6,25 +6,6 @@ import { AuthHttpServiceInterface } from '../../Domain/Auth/AuthHttpServiceInter
export class AuthHttpService implements AuthHttpServiceInterface {
constructor(private httpClient: AxiosInstance, private authServerUrl: string) {}
async getUserSetting(userUuid: string, settingName: string): Promise<{ uuid: string; value: string | null }> {
const response = await this.httpClient.request({
method: 'GET',
headers: {
Accept: 'application/json',
},
url: `${this.authServerUrl}/internal/users/${userUuid}/settings/${settingName}`,
validateStatus:
/* istanbul ignore next */
(status: number) => status >= 200 && status < 500,
})
if (!response.data.setting) {
throw new Error('Missing user setting from auth service response')
}
return response.data.setting
}
async getUserKeyParams(dto: { email?: string; uuid?: string; authenticated: boolean }): Promise<KeyParamsData> {
const keyParamsResponse = await this.httpClient.request({
method: 'GET',