Skip to content

Commit

Permalink
Add Amazon Cognito SSO support to iDempiere bxservice#252
Browse files Browse the repository at this point in the history
  • Loading branch information
etantg committed Oct 10, 2024
1 parent dda6e8d commit 3ba7b30
Show file tree
Hide file tree
Showing 8 changed files with 812 additions and 116 deletions.
3 changes: 2 additions & 1 deletion com.trekglobal.idempiere.rest.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ Export-Package: com.trekglobal.idempiere.rest.api,
Service-Component: OSGI-INF/com.trekglobal.idempiere.rest.api.json.DefaultGridTabSerializer.xml,
OSGI-INF/com.trekglobal.idempiere.rest.api.json.DefaultPOSerializer.xml,
OSGI-INF/com.trekglobal.idempiere.rest.api.json.DefaultQueryConverter.xml,
OSGI-INF/com.trekglobal.idempiere.rest.api.oidc.keycloak.KeycloakProvider.xml
OSGI-INF/com.trekglobal.idempiere.rest.api.oidc.keycloak.KeycloakProvider.xml,
OSGI-INF/com.trekglobal.idempiere.rest.api.oidc.amazoncognito.AmazonCognitoProvider.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="com.trekglobal.idempiere.rest.api.oidc.amazoncognito.AmazonCognitoProvider">
<property name="name" value="Amazon Cognito"/>
<service>
<provide interface="com.trekglobal.idempiere.rest.api.oidc.IOIDCProvider"/>
</service>
<implementation class="com.trekglobal.idempiere.rest.api.oidc.amazoncognito.AmazonCognitoProvider"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
{
"info": {
"_postman_id": "9671d7a1-8fa9-4731-80ef-57d144c5afcd",
"name": "amazon-cognito-oidc-test",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "27359776",
"_collection_link": "https://lunar-astronaut-434175.postman.co/workspace/GraphQL-Wrapper-for-iDempiere-R~c90f44fb-2bfc-4c52-8da6-093a705eddf2/collection/27359776-9671d7a1-8fa9-4731-80ef-57d144c5afcd?action=share&source=collection_link&creator=27359776"
},
"item": [
{
"name": "Get Token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.environment.set(\"AccessToken\", jsonData.AuthenticationResult.AccessToken);",
"pm.environment.set(\"IdToken\", jsonData.AuthenticationResult.IdToken);",
"pm.environment.set(\"RefreshToken\", jsonData.AuthenticationResult.RefreshToken);",
"pm.environment.set(\"TokenType\", jsonData.AuthenticationResult.TokenType);"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-amz-json-1.1",
"type": "text"
},
{
"key": "X-Amz-Target",
"value": "AWSCognitoIdentityProviderService.InitiateAuth",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"AuthFlow\": \"USER_PASSWORD_AUTH\",\r\n \"AuthParameters\": {\r\n \"USERNAME\": \"{{cognitoUsername}}\",\r\n \"PASSWORD\": \"{{cognitoPassword}}\",\r\n \"SECRET_HASH\": \"{{cognitoSecretHash}}\"\r\n },\r\n \"ClientId\": \"{{cognitoClientId}}\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://cognito-idp.{{cognitoRegion}}.amazonaws.com",
"protocol": "https",
"host": [
"cognito-idp",
"{{cognitoRegion}}",
"amazonaws",
"com"
]
}
},
"response": []
},
{
"name": "Refresh Token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.environment.set(\"AccessToken\", jsonData.AuthenticationResult.AccessToken);",
"pm.environment.set(\"IdToken\", jsonData.AuthenticationResult.IdToken);",
"pm.environment.set(\"TokenType\", jsonData.AuthenticationResult.TokenType);",
"if (jsonData.AuthenticationResult.RefreshToken != null)",
" pm.environment.set(\"RefreshToken\", jsonData.AuthenticationResult.RefreshToken);"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-amz-json-1.1",
"type": "text"
},
{
"key": "X-Amz-Target",
"value": "AWSCognitoIdentityProviderService.InitiateAuth",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"AuthFlow\": \"REFRESH_TOKEN_AUTH\",\r\n \"AuthParameters\": {\r\n \"REFRESH_TOKEN\": \"{{RefreshToken}}\",\r\n \"SECRET_HASH\": \"{{cognitoSecretHash}}\"\r\n },\r\n \"ClientId\": \"{{cognitoClientId}}\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://cognito-idp.{{cognitoRegion}}.amazonaws.com",
"protocol": "https",
"host": [
"cognito-idp",
"{{cognitoRegion}}",
"amazonaws",
"com"
]
}
},
"response": []
},
{
"name": "api/v1/models/{table name}?filter={where clause}",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Accept",
"value": "application/json",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer {{AccessToken}}",
"type": "text"
},
{
"key": "IdToken",
"value": "{{IdToken}}",
"type": "text"
}
],
"url": {
"raw": "{{protocol}}://{{host}}:{{port}}/api/v1/models/C_Tax?filter=C_TaxCategory_ID=107",
"protocol": "{{protocol}}",
"host": [
"{{host}}"
],
"port": "{{port}}",
"path": [
"api",
"v1",
"models",
"C_Tax"
],
"query": [
{
"key": "filter",
"value": "C_TaxCategory_ID=107"
}
]
}
},
"response": []
},
{
"name": "api/v1/models/{table name}?select={columnname list}",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Accept",
"value": "application/json",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer {{AccessToken}}",
"type": "text"
},
{
"key": "IdToken",
"value": "{{IdToken}}",
"type": "text"
}
],
"url": {
"raw": "{{protocol}}://{{host}}:{{port}}/api/v1/models/C_Order?select=DocumentNo,Description",
"protocol": "{{protocol}}",
"host": [
"{{host}}"
],
"port": "{{port}}",
"path": [
"api",
"v1",
"models",
"C_Order"
],
"query": [
{
"key": "select",
"value": "DocumentNo,Description"
}
]
}
},
"response": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"id": "0d637021-95f8-45c9-8fc1-91e3982106ca",
"name": "environment-http://localhost:8080",
"values": [
{
"key": "protocol",
"value": "http",
"enabled": true
},
{
"key": "host",
"value": "localhost",
"enabled": true
},
{
"key": "port",
"value": "8080",
"enabled": true
},
{
"key": "userName",
"value": "GardenAdmin",
"enabled": true
},
{
"key": "password",
"value": "GardenAdmin",
"type": "secret",
"enabled": true
},
{
"key": "clientId",
"value": "11",
"enabled": true
},
{
"key": "roleId",
"value": "102",
"enabled": true
},
{
"key": "organizationId",
"value": "11",
"enabled": true
},
{
"key": "warehouseId",
"value": "103",
"enabled": true
},
{
"key": "language",
"value": "en_US",
"enabled": true
},
{
"key": "sysuserName",
"value": "SuperUser",
"enabled": true
},
{
"key": "syspassword",
"value": "System",
"enabled": true
},
{
"key": "AccessToken",
"value": "",
"type": "any",
"enabled": true
},
{
"key": "RefreshToken",
"value": "",
"type": "any",
"enabled": true
},
{
"key": "cognitoRegion",
"value": "ap-southeast-2",
"type": "default",
"enabled": true
},
{
"key": "cognitoUsername",
"value": "GardenAdmin",
"type": "default",
"enabled": true
},
{
"key": "cognitoPassword",
"value": "",
"type": "secret",
"enabled": true
},
{
"key": "cognitoSecretHash",
"value": "",
"type": "secret",
"enabled": true
},
{
"key": "cognitoClientId",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "IdToken",
"value": "",
"type": "any",
"enabled": true
},
{
"key": "TokenType",
"value": "",
"type": "any",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2024-10-10T03:56:28.649Z",
"_postman_exported_using": "Postman/11.16.0"
}
Loading

0 comments on commit 3ba7b30

Please sign in to comment.