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

[#171549246] Add function to create a new user #30

Merged
merged 11 commits into from
Mar 13, 2020
Merged

Conversation

alexgpeppe
Copy link
Contributor

This PR aims to create a User on the Active Directory Azure B2C and on the API Management.

toError
).map(
credentials =>
// the below cast to `any` is needed to prevent build errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be solved using 4.x version of azure graph package:

https://github.com/gunzip/adb2c-apim-migrate/blob/master/package.json#L8

@@ -280,6 +280,26 @@ paths:
description: List of users
schema:
$ref: "#/definitions/UserCollection"
post:
summary: Create user
description: Create a new User with a random password on the Active Directory Azure B2C and create the corresponding User on the APIM.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: Create a new User with a random password on the Active Directory Azure B2C and create the corresponding User on the APIM.
description: Create a new user with a random password in the Active Directory Azure B2C, then create a corresponding user on the API management resource.

README.md Outdated
@@ -19,6 +19,9 @@ they may be customized as needed.
| SERVICE_PRINCIPAL_CLIENT_ID | The service principal name used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_SECRET | The service principal secret used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_TENANT_ID | The service principal tenant id used to get the token credentials to connect to the APIM | string |
| ADB2C_CLIENT_ID | The service principal name used to get the token credentials to connect to the ADB2C | string |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are parameters relative to an application registered into the ADB2C tenant

README.md Outdated
@@ -19,6 +19,9 @@ they may be customized as needed.
| SERVICE_PRINCIPAL_CLIENT_ID | The service principal name used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_SECRET | The service principal secret used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_TENANT_ID | The service principal tenant id used to get the token credentials to connect to the APIM | string |
| ADB2C_CLIENT_ID | The service principal name used to get the token credentials to connect to the ADB2C | string |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| ADB2C_CLIENT_ID | The service principal name used to get the token credentials to connect to the ADB2C | string |
| ADB2C_CLIENT_ID | The application client id used to get the token credentials to connect to the ADB2C | string |

README.md Outdated
@@ -19,6 +19,9 @@ they may be customized as needed.
| SERVICE_PRINCIPAL_CLIENT_ID | The service principal name used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_SECRET | The service principal secret used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_TENANT_ID | The service principal tenant id used to get the token credentials to connect to the APIM | string |
| ADB2C_CLIENT_ID | The service principal name used to get the token credentials to connect to the ADB2C | string |
| ADB2C_CLIENT_KEY | The service principal secret used to get the token credentials to connect to the ADB2C | string |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| ADB2C_CLIENT_KEY | The service principal secret used to get the token credentials to connect to the ADB2C | string |
| ADB2C_CLIENT_KEY | The application secret used to get the token credentials to connect to the ADB2C | string |

README.md Outdated
@@ -19,6 +19,9 @@ they may be customized as needed.
| SERVICE_PRINCIPAL_CLIENT_ID | The service principal name used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_SECRET | The service principal secret used to get the token credentials to connect to the APIM | string |
| SERVICE_PRINCIPAL_TENANT_ID | The service principal tenant id used to get the token credentials to connect to the APIM | string |
| ADB2C_CLIENT_ID | The service principal name used to get the token credentials to connect to the ADB2C | string |
| ADB2C_CLIENT_KEY | The service principal secret used to get the token credentials to connect to the ADB2C | string |
| ADB2C_TENANT_ID | The service principal tenant id used to get the token credentials to connect to the ADB2C | string |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| ADB2C_TENANT_ID | The service principal tenant id used to get the token credentials to connect to the ADB2C | string |
| ADB2C_TENANT_ID | The ADB2C tenant id | string |

.chain(userCreateResponse =>
getApiClient(apimCredentials, azureApimConfig.subscriptionId)
.mapLeft(error =>
internalErrorHandler("Could not get the APIM client", error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
internalErrorHandler("Could not get the APIM client", error)
internalErrorHandler("Could not get the API management client", error)

taskResults.apimClient.user.createOrUpdate(
azureApimConfig.apimResourceGroup,
azureApimConfig.apim,
taskResults.userId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

``

Suggested change
taskResults.userId,
taskResults.objectId,

azureApimConfig.apimResourceGroup,
azureApimConfig.apim,
taskResults.userId,
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you must link the adb2c identity to the one generated into the adb2c, see this code:

https://github.com/gunzip/adb2c-apim-migrate/blob/master/migrate.ts#L280

@alexgpeppe alexgpeppe marked this pull request as ready for review March 13, 2020 09:17
@alexgpeppe alexgpeppe requested a review from gunzip March 13, 2020 09:17
CreateUser/handler.ts Outdated Show resolved Hide resolved
@gunzip gunzip merged commit 27aaad0 into master Mar 13, 2020
@gunzip gunzip deleted the 171549246-create-user branch March 13, 2020 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants