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

chore(ids-api): Configure syslumenn client to use xroad #16265

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
14 changes: 8 additions & 6 deletions apps/services/auth/ids-api/infra/ids-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { json, service, ServiceBuilder } from '../../../../../infra/src/dsl/dsl'
import {
Base,
Client,
DistrictCommissionersWorkSystem,
NationalRegistryAuthB2C,
RskProcuring,
} from '../../../../../infra/src/dsl/xroad'
Expand Down Expand Up @@ -83,11 +84,6 @@ export const serviceSetup = (): ServiceBuilder<'services-auth-ids-api'> => {
// Origin for Android prod app
'android:apk-key-hash:EsLTUu5kaY7XPmMl2f7nbq4amu-PNzdYu3FecNf90wU',
]),
SYSLUMENN_HOST: {
dev: 'https://api.syslumenn.is/staging',
staging: 'https://api.syslumenn.is/staging',
prod: 'https://api.syslumenn.is/api',
},
SYSLUMENN_TIMEOUT: '3000',
})
.secrets({
Expand All @@ -101,7 +97,13 @@ export const serviceSetup = (): ServiceBuilder<'services-auth-ids-api'> => {
SYSLUMENN_USERNAME: '/k8s/services-auth/SYSLUMENN_USERNAME',
SYSLUMENN_PASSWORD: '/k8s/services-auth/SYSLUMENN_PASSWORD',
})
.xroad(Base, Client, RskProcuring, NationalRegistryAuthB2C)
.xroad(
Base,
Client,
RskProcuring,
NationalRegistryAuthB2C,
DistrictCommissionersWorkSystem,
)
valurefugl marked this conversation as resolved.
Show resolved Hide resolved
.readiness('/health/check')
.liveness('/liveness')
.db({ name: 'servicesauth', extensions: ['uuid-ossp'] })
Expand Down
2 changes: 1 addition & 1 deletion charts/identity-server/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ services-auth-ids-api:
PUBLIC_URL: 'https://identity-server.dev01.devland.is/api'
REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]'
SERVERSIDE_FEATURES_ON: ''
SYSLUMENN_HOST: 'https://api.syslumenn.is/staging'
SYSLUMENN_TIMEOUT: '3000'
USER_PROFILE_CLIENT_SCOPE: '["@island.is/user-profile:read"]'
USER_PROFILE_CLIENT_URL: 'http://web-service-portal-api.service-portal.svc.cluster.local'
XROAD_BASE_PATH: 'http://securityserver.dev01.devland.is'
XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.dev01.devland.is/r1/IS-DEV'
XROAD_CLIENT_ID: 'IS-DEV/GOV/10000/island-is-client'
XROAD_DISTRICT_COMMISSIONERS_LICENSES_PATH: 'IS-DEV/GOV/10016/Syslumenn-Protected/StarfsKerfi'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]'
XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS-DEV/GOV/10001/SKRA-Protected/Einstaklingar-v1'
XROAD_RSK_PROCURING_PATH: 'IS-DEV/GOV/10006/Skatturinn/relationships-v1'
Expand Down
2 changes: 1 addition & 1 deletion charts/identity-server/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@ services-auth-ids-api:
PUBLIC_URL: 'https://innskra.island.is/api'
REDIS_NODES: '["clustercfg.general-redis-cluster-group.dnugi2.euw1.cache.amazonaws.com:6379"]'
SERVERSIDE_FEATURES_ON: 'driving-license-use-v1-endpoint-for-v2-comms'
SYSLUMENN_HOST: 'https://api.syslumenn.is/api'
SYSLUMENN_TIMEOUT: '3000'
USER_PROFILE_CLIENT_SCOPE: '["@island.is/user-profile:read"]'
USER_PROFILE_CLIENT_URL: 'https://service-portal-api.internal.island.is'
XROAD_BASE_PATH: 'http://securityserver.island.is'
XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.island.is/r1/IS'
XROAD_CLIENT_ID: 'IS/GOV/5501692829/island-is-client'
XROAD_DISTRICT_COMMISSIONERS_LICENSES_PATH: 'IS/GOV/5512201410/Syslumenn-Protected/StarfsKerfi'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.dnugi2.euw1.cache.amazonaws.com:6379"]'
XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS/GOV/6503760649/SKRA-Protected/Einstaklingar-v1'
XROAD_RSK_PROCURING_PATH: 'IS/GOV/5402696029/Skatturinn/relationships-v1'
Expand Down
2 changes: 1 addition & 1 deletion charts/identity-server/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ services-auth-ids-api:
PUBLIC_URL: 'https://identity-server.staging01.devland.is/api'
REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]'
SERVERSIDE_FEATURES_ON: ''
SYSLUMENN_HOST: 'https://api.syslumenn.is/staging'
SYSLUMENN_TIMEOUT: '3000'
USER_PROFILE_CLIENT_SCOPE: '["@island.is/user-profile:read"]'
USER_PROFILE_CLIENT_URL: 'http://web-service-portal-api.service-portal.svc.cluster.local'
XROAD_BASE_PATH: 'http://securityserver.staging01.devland.is'
XROAD_BASE_PATH_WITH_ENV: 'http://securityserver.staging01.devland.is/r1/IS-TEST'
XROAD_CLIENT_ID: 'IS-TEST/GOV/5501692829/island-is-client'
XROAD_DISTRICT_COMMISSIONERS_LICENSES_PATH: 'IS-TEST/GOV/10016/Syslumenn-Protected/StarfsKerfi'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]'
XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS-TEST/GOV/6503760649/SKRA-Protected/Einstaklingar-v1'
XROAD_RSK_PROCURING_PATH: 'IS-TEST/GOV/5402696029/Skatturinn/relationships-v1'
Expand Down
9 changes: 9 additions & 0 deletions infra/src/dsl/xroad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ export const DistrictCommissionersLicenses = new XroadConf({
},
},
})
export const DistrictCommissionersWorkSystem = new XroadConf({
env: {
XROAD_DISTRICT_COMMISSIONERS_LICENSES_PATH: {
dev: 'IS-DEV/GOV/10016/Syslumenn-Protected/StarfsKerfi',
staging: 'IS-TEST/GOV/10016/Syslumenn-Protected/StarfsKerfi',
prod: 'IS/GOV/5512201410/Syslumenn-Protected/StarfsKerfi',
},
},
})

export const Firearm = new XroadConf({
env: {
Expand Down
31 changes: 31 additions & 0 deletions libs/clients/syslumenn/src/lib/apiConfiguration.ts
valurefugl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { createEnhancedFetch } from '@island.is/clients/middlewares'
import { ConfigType, XRoadConfig } from '@island.is/nest/config'

import { Configuration } from '../../gen/fetch'
import { SyslumennClientConfig } from './syslumennClient.config'

export const ApiConfiguration = {
provide: 'SyslumennClientApiConfiguration',
useFactory: (
xRoadConfig: ConfigType<typeof XRoadConfig>,
config: ConfigType<typeof SyslumennClientConfig>,
) =>
new Configuration({
fetchApi: createEnhancedFetch({
name: 'clients-syslumenn',
organizationSlug: 'syslumenn',
...config.fetch,
}),
basePath: config.xRoadServicePath
? `${xRoadConfig.xRoadBasePath}/${config.xRoadServicePath}`
: config.url,
headers: {
...(config.xRoadServicePath && {
'X-Road-Client': xRoadConfig.xRoadClient,
}),
'Content-Type': 'application/json',
Accept: 'application/json',
},
}),
inject: [XRoadConfig.KEY, SyslumennClientConfig.KEY],
}
12 changes: 9 additions & 3 deletions libs/clients/syslumenn/src/lib/syslumennClient.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { defineConfig } from '@island.is/nest/config'
import { z } from 'zod'

import { defineConfig } from '@island.is/nest/config'

const schema = z.object({
url: z.string(),
url: z.optional(z.string()),
fetch: z.object({
timeout: z.number().int(),
}),
username: z.string(),
password: z.string(),
xRoadServicePath: z.optional(z.string()),
})

export const SyslumennClientConfig = defineConfig({
name: 'SyslumennApi',
schema,
load(env) {
return {
url: env.required('SYSLUMENN_HOST', 'https://api.syslumenn.is/staging'),
url: env.optional('SYSLUMENN_HOST', 'https://api.syslumenn.is/staging'),
fetch: {
timeout: env.optionalJSON('SYSLUMENN_TIMEOUT') ?? 40000,
},
username: env.required('SYSLUMENN_USERNAME'),
password: env.required('SYSLUMENN_PASSWORD'),
xRoadServicePath: env.optional(
'XROAD_DISTRICT_COMMISSIONERS_WORK_SYSTEM_PATH',
'r1/IS-DEV/GOV/10016/Syslumenn-Protected/StarfsKerfi',
),
}
},
})
4 changes: 3 additions & 1 deletion libs/clients/syslumenn/src/lib/syslumennClient.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'

import { ApiConfiguration } from './apiConfiguration'
import { SyslumennService } from './syslumennClient.service'

@Module({
providers: [SyslumennService],
providers: [SyslumennService, ApiConfiguration],
exports: [SyslumennService],
})
export class SyslumennClientModule {}
18 changes: 4 additions & 14 deletions libs/clients/syslumenn/src/lib/syslumennClient.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
VedbondTegundAndlags,
VirkLeyfiGetRequest,
} from '../../gen/fetch'
import { ApiConfiguration } from './apiConfiguration'
import { SyslumennClientConfig } from './syslumennClient.config'
import {
AlcoholLicence,
Expand Down Expand Up @@ -81,25 +82,14 @@ const UPLOAD_DATA_SUCCESS = 'Gögn móttekin'
@Injectable()
export class SyslumennService {
constructor(
@Inject(ApiConfiguration.provide)
private apiConfig: Configuration,
@Inject(SyslumennClientConfig.KEY)
private clientConfig: ConfigType<typeof SyslumennClientConfig>,
) {}

private async createApi() {
const api = new SyslumennApi(
new Configuration({
fetchApi: createEnhancedFetch({
name: 'clients-syslumenn',
organizationSlug: 'syslumenn',
...this.clientConfig.fetch,
}),
basePath: this.clientConfig.url,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}),
)
const api = new SyslumennApi(this.apiConfig)

const config = {
notandi: this.clientConfig.username,
Expand Down
Loading