-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tenant-management): integrate auth0
integrate auth0 GH-47
- Loading branch information
1 parent
f14113b
commit 0ecf67f
Showing
22 changed files
with
685 additions
and
276 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 55 additions & 55 deletions
110
services/tenant-management-service/src/controllers/idp.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
import { inject, intercept } from '@loopback/core'; | ||
import { getModelSchemaRef, post, requestBody } from '@loopback/rest'; | ||
import {inject, intercept} from '@loopback/core'; | ||
import {getModelSchemaRef, post, requestBody} from '@loopback/rest'; | ||
import { | ||
CONTENT_TYPE, | ||
OPERATION_SECURITY_SPEC, | ||
rateLimitKeyGenPublic, | ||
STATUS_CODE, | ||
CONTENT_TYPE, | ||
OPERATION_SECURITY_SPEC, | ||
rateLimitKeyGenPublic, | ||
STATUS_CODE, | ||
} from '@sourceloop/core'; | ||
import { authorize } from 'loopback4-authorization'; | ||
import { ratelimit } from 'loopback4-ratelimiter'; | ||
import { TenantManagementServiceBindings, WEBHOOK_VERIFIER } from '../keys'; | ||
import { IdpDetailsDTO } from '../models/dtos/idp-details-dto.model'; | ||
import { ConfigureIdpFunc, IdPKey } from '../types'; | ||
import {authorize} from 'loopback4-authorization'; | ||
import {ratelimit} from 'loopback4-ratelimiter'; | ||
import {TenantManagementServiceBindings, WEBHOOK_VERIFIER} from '../keys'; | ||
import {IdpDetailsDTO} from '../models/dtos/idp-details-dto.model'; | ||
import {ConfigureIdpFunc, IdPKey} from '../types'; | ||
|
||
const basePath = '/manage/users'; | ||
export class IdpController { | ||
constructor( | ||
@inject(TenantManagementServiceBindings.IDP_KEYCLOAK) | ||
private readonly idpKeycloakProvider:ConfigureIdpFunc<IdpDetailsDTO> | ||
) { } | ||
@intercept(WEBHOOK_VERIFIER) | ||
@ratelimit(true, { | ||
max: parseInt(process.env.WEBHOOK_API_MAX_ATTEMPTS ?? '10'), | ||
keyGenerator: rateLimitKeyGenPublic, | ||
}) | ||
@authorize({ | ||
permissions: ['*'], | ||
}) | ||
@post(`${basePath}`, { | ||
security: OPERATION_SECURITY_SPEC, | ||
responses: { | ||
[STATUS_CODE.NO_CONTENT]: { | ||
description: 'Webhook success', | ||
}, | ||
constructor( | ||
@inject(TenantManagementServiceBindings.IDP_KEYCLOAK) | ||
private readonly idpKeycloakProvider: ConfigureIdpFunc<IdpDetailsDTO>, | ||
@inject(TenantManagementServiceBindings.IDP_AUTH0) | ||
private readonly idpAuth0Provider: ConfigureIdpFunc<IdpDetailsDTO>, | ||
) {} | ||
@intercept(WEBHOOK_VERIFIER) | ||
@ratelimit(true, { | ||
max: parseInt(process.env.WEBHOOK_API_MAX_ATTEMPTS ?? '10'), | ||
keyGenerator: rateLimitKeyGenPublic, | ||
}) | ||
@authorize({ | ||
permissions: ['*'], | ||
}) | ||
@post(`${basePath}`, { | ||
security: OPERATION_SECURITY_SPEC, | ||
responses: { | ||
[STATUS_CODE.NO_CONTENT]: { | ||
description: 'Webhook success', | ||
}, | ||
}, | ||
}) | ||
async idpConfigure( | ||
@requestBody({ | ||
content: { | ||
[CONTENT_TYPE.JSON]: { | ||
schema: getModelSchemaRef(IdpDetailsDTO, { | ||
title: 'IdpDetailsDTO', | ||
}), | ||
}, | ||
}, | ||
}) | ||
async idpConfigure( | ||
@requestBody({ | ||
content: { | ||
[CONTENT_TYPE.JSON]: { | ||
schema: getModelSchemaRef(IdpDetailsDTO, { | ||
title: 'IdpDetailsDTO', | ||
}), | ||
}, | ||
}, | ||
}) | ||
payload: IdpDetailsDTO, | ||
): Promise<void> { | ||
switch (payload.identityProvider) { | ||
case IdPKey.AUTH0: | ||
|
||
break; | ||
case IdPKey.COGNITO: | ||
|
||
break; | ||
case IdPKey.KEYCLOAK: | ||
await this.idpKeycloakProvider(payload); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
payload: IdpDetailsDTO, | ||
): Promise<void> { | ||
switch (payload.identityProvider) { | ||
case IdPKey.AUTH0: | ||
await this.idpAuth0Provider(payload); | ||
break; | ||
case IdPKey.COGNITO: | ||
break; | ||
case IdPKey.KEYCLOAK: | ||
await this.idpKeycloakProvider(payload); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
} |
35 changes: 18 additions & 17 deletions
35
services/tenant-management-service/src/controllers/tenant-config-tenant.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.