mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
shift core/auth/jwt to shared/jwt and correct usage
This commit is contained in:
parent
247038741c
commit
abdf5de31d
@ -7,9 +7,10 @@ import { AuthenticationClient as V1_0_AuthenticationClient } from '@/federation/
|
||||
import { ensureUrlEndsWithSlash } from '@/util/utilities'
|
||||
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '@/config/const'
|
||||
import { encryptAndSign, EncryptedTransferArgs, OpenConnectionJwtPayloadType } from 'core'
|
||||
import { encryptAndSign, OpenConnectionJwtPayloadType } from 'shared'
|
||||
import { getLogger } from 'log4js'
|
||||
import { AuthenticationClientFactory } from './client/AuthenticationClientFactory'
|
||||
import { EncryptedTransferArgs } from 'core'
|
||||
|
||||
const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.federation.authenticateCommunities`)
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import {
|
||||
Community as DbCommunity,
|
||||
FederatedCommunity as DbFederatedCommunity,
|
||||
FederatedCommunityLoggingView,
|
||||
getHomeCommunity,
|
||||
} from 'database'
|
||||
import { IsNull } from 'typeorm'
|
||||
|
||||
@ -10,7 +11,7 @@ import { FederationClient as V1_0_FederationClient } from '@/federation/client/1
|
||||
import { PublicCommunityInfo } from '@/federation/client/1_0/model/PublicCommunityInfo'
|
||||
import { FederationClientFactory } from '@/federation/client/FederationClientFactory'
|
||||
import { LogError } from '@/server/LogError'
|
||||
import { createKeyPair } from 'core'
|
||||
import { createKeyPair } from 'shared'
|
||||
import { getLogger } from 'log4js'
|
||||
import { startCommunityAuthentication } from './authenticateCommunities'
|
||||
import { PublicCommunityInfoLoggingView } from './client/1_0/logging/PublicCommunityInfoLogging.view'
|
||||
@ -85,13 +86,13 @@ export async function writeJwtKeyPairInHomeCommunity(): Promise<DbCommunity> {
|
||||
logger.debug(`Federation: writeJwtKeyPairInHomeCommunity`)
|
||||
try {
|
||||
// check for existing homeCommunity entry
|
||||
let homeCom = await DbCommunity.findOne({ where: { foreign: false } })
|
||||
let homeCom = await getHomeCommunity()
|
||||
if (homeCom) {
|
||||
if (!homeCom.publicJwtKey && !homeCom.privateJwtKey) {
|
||||
// Generate key pair using jose library
|
||||
const { publicKey, privateKey } = await createKeyPair();
|
||||
logger.debug(`Federation: writeJwtKeyPairInHomeCommunity publicKey=`, publicKey);
|
||||
logger.debug(`Federation: writeJwtKeyPairInHomeCommunity privateKey=`, privateKey);
|
||||
logger.debug(`Federation: writeJwtKeyPairInHomeCommunity privateKey=`, privateKey.slice(0, 20));
|
||||
|
||||
homeCom.publicJwtKey = publicKey;
|
||||
logger.debug(`Federation: writeJwtKeyPairInHomeCommunity publicJwtKey.length=`, homeCom.publicJwtKey.length);
|
||||
|
||||
@ -39,12 +39,10 @@ import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
||||
import { TRANSACTION_LINK_LOCK } from '@/util/TRANSACTION_LINK_LOCK'
|
||||
import { fullName } from '@/util/utilities'
|
||||
import { calculateBalance } from '@/util/validate'
|
||||
import { RedeemJwtPayloadType, decode, encode, verify } from 'core'
|
||||
import { calculateDecay } from 'shared'
|
||||
import { calculateDecay, decode, DisburseJwtPayloadType, encode, RedeemJwtPayloadType, verify } from 'shared'
|
||||
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '@/config/const'
|
||||
import { DisburseJwtPayloadType } from 'core'
|
||||
import { Logger, getLogger } from 'log4js'
|
||||
import { getLogger, Logger } from 'log4js'
|
||||
import { executeTransaction } from './TransactionResolver'
|
||||
import {
|
||||
getAuthenticatedCommunities,
|
||||
|
||||
@ -1,12 +1,3 @@
|
||||
export * from './validation/user'
|
||||
export * from './auth/jwt/JWT'
|
||||
export * from './auth/jwt/payloadtypes/AuthenticationJwtPayloadType'
|
||||
export * from './auth/jwt/payloadtypes/AuthenticationResponseJwtPayloadType'
|
||||
export * from './auth/jwt/payloadtypes/DisburseJwtPayloadType'
|
||||
export * from './auth/jwt/payloadtypes/EncryptedJWEJwtPayloadType'
|
||||
export * from './auth/jwt/payloadtypes/JwtPayloadType'
|
||||
export * from './auth/jwt/payloadtypes/OpenConnectionJwtPayloadType'
|
||||
export * from './auth/jwt/payloadtypes/OpenConnectionCallbackJwtPayloadType'
|
||||
export * from './auth/jwt/payloadtypes/RedeemJwtPayloadType'
|
||||
export * from './graphql/logic/interpretEncryptedTransferArgs'
|
||||
export * from './graphql/model/EncryptedTransferArgs'
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { CONFIG } from '@/config'
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '@/config/const'
|
||||
import { AuthenticationJwtPayloadType, AuthenticationResponseJwtPayloadType, encryptAndSign, EncryptedTransferArgs, interpretEncryptedTransferArgs, OpenConnectionCallbackJwtPayloadType, OpenConnectionJwtPayloadType } from 'core'
|
||||
import { EncryptedTransferArgs, interpretEncryptedTransferArgs } from 'core'
|
||||
import {
|
||||
CommunityLoggingView,
|
||||
Community as DbCommunity,
|
||||
@ -9,6 +9,7 @@ import {
|
||||
getHomeCommunity,
|
||||
} from 'database'
|
||||
import { getLogger } from 'log4js'
|
||||
import { AuthenticationJwtPayloadType, AuthenticationResponseJwtPayloadType, encryptAndSign, OpenConnectionCallbackJwtPayloadType, OpenConnectionJwtPayloadType } from 'shared'
|
||||
import { Arg, Mutation, Resolver } from 'type-graphql'
|
||||
import { startAuthentication, startOpenConnectionCallback } from '../util/authenticateCommunity'
|
||||
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
export const DECAY_START_TIME = new Date('2021-05-13T17:46:31Z')
|
||||
export const LOG4JS_BASE_CATEGORY_NAME = 'shared'
|
||||
export const LOG4JS_BASE_CATEGORY_NAME = 'shared'
|
||||
export const REDEEM_JWT_TOKEN_EXPIRATION = '10m'
|
||||
@ -1,3 +1,12 @@
|
||||
export * from './schema'
|
||||
export * from './enum'
|
||||
export * from './logic/decay'
|
||||
export * from './jwt/JWT'
|
||||
export * from './jwt/payloadtypes/AuthenticationJwtPayloadType'
|
||||
export * from './jwt/payloadtypes/AuthenticationResponseJwtPayloadType'
|
||||
export * from './jwt/payloadtypes/DisburseJwtPayloadType'
|
||||
export * from './jwt/payloadtypes/EncryptedJWEJwtPayloadType'
|
||||
export * from './jwt/payloadtypes/JwtPayloadType'
|
||||
export * from './jwt/payloadtypes/OpenConnectionJwtPayloadType'
|
||||
export * from './jwt/payloadtypes/OpenConnectionCallbackJwtPayloadType'
|
||||
export * from './jwt/payloadtypes/RedeemJwtPayloadType'
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { generateKeyPair, exportSPKI, exportPKCS8, SignJWT, decodeJwt, importPKCS8, importSPKI, jwtVerify, CompactEncrypt, compactDecrypt } from 'jose'
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '../../config/const'
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '../const'
|
||||
import { getLogger } from 'log4js'
|
||||
|
||||
const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.auth.jwt.JWT`)
|
||||
@ -1,6 +1,6 @@
|
||||
import { JWTPayload } from 'jose'
|
||||
|
||||
import { REDEEM_JWT_TOKEN_EXPIRATION } from '../../../config/const'
|
||||
import { REDEEM_JWT_TOKEN_EXPIRATION } from '../../const'
|
||||
|
||||
export class JwtPayloadType implements JWTPayload {
|
||||
static ISSUER = 'urn:gradido:issuer'
|
||||
@ -1,4 +1,3 @@
|
||||
// import { JWTPayload } from 'jose'
|
||||
import { JwtPayloadType } from './JwtPayloadType'
|
||||
|
||||
export class OpenConnectionCallbackJwtPayloadType extends JwtPayloadType {
|
||||
@ -1,4 +1,3 @@
|
||||
// import { JWTPayload } from 'jose'
|
||||
import { JwtPayloadType } from './JwtPayloadType'
|
||||
|
||||
export class OpenConnectionJwtPayloadType extends JwtPayloadType {
|
||||
@ -1,4 +1,3 @@
|
||||
// import { JWTPayload } from 'jose'
|
||||
import { JwtPayloadType } from './JwtPayloadType'
|
||||
|
||||
export class RedeemJwtPayloadType extends JwtPayloadType {
|
||||
Loading…
x
Reference in New Issue
Block a user