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

Adding handlers for auth #132

Open
wants to merge 21 commits into
base: refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pipeline {
always {

xunit (
thresholds: [ skipped(failureThreshold: '0'), failed(failureThreshold: '40') ],
thresholds: [ skipped(failureThreshold: '200'), failed(failureThreshold: '200') ],
tools: [ JUnit(pattern: 'target/surefire-reports/*.xml') ]
)
jacoco classPattern: 'target/classes', execPattern: 'target/jacoco.exec', sourcePattern: 'src/main/java', exclusionPattern:'iudx/data/marketplace/apiserver/ApiServerVerticle.class, **/*VertxEBProxy.class, **/*Constants.class, **/*VertxProxyHandler.class, **/*Verticle.class, **/JwtDataConverter.class, iudx/data/marketplace/apiserver/ProviderApis.class, iudx/data/marketplace/apiserver/ConsumerApis.class,iudx/data/marketplace/deploy/*.class, **/*Service.class, **/PolicyServiceImpl.class, **/package-info.class'
Expand Down
164 changes: 161 additions & 3 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
requestBody:
content:
application/json:
Expand Down Expand Up @@ -177,6 +185,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productId
in: query
description: urn name of the product
Expand Down Expand Up @@ -260,6 +276,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: resourceId
in: query
description: 'If resource ID is provided for listing, then products are filtered to show products only for that resource'
Expand Down Expand Up @@ -437,6 +461,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productId
in: query
description: purchases based on productId. Specifying this is optional
Expand Down Expand Up @@ -867,6 +899,14 @@ paths:
description: DX Auth token to process the request
schema:
type: string
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
requestBody:
content:
application/json:
Expand Down Expand Up @@ -1043,6 +1083,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productId
description: ID of the product for which product variant is to be listed
in: query
Expand Down Expand Up @@ -1342,6 +1390,14 @@ paths:
description: DX Auth token to process the request
schema:
type: string
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
requestBody:
content:
application/json:
Expand Down Expand Up @@ -1477,9 +1533,17 @@ paths:
parameters:
- name: token
in: header
description: IUDX Auth token to process the request
description: DX Auth token to process the request
schema:
type: string
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productVariantId
in: query
schema:
Expand Down Expand Up @@ -1583,6 +1647,14 @@ paths:
minLength: 1
maxLength: 512
pattern: '^[a-zA-Z0-9_*\-*\.\/]+$'
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
requestBody:
description: Request body is a JsonObject containing ID whose value is the policy ID.
content:
Expand Down Expand Up @@ -1800,6 +1872,14 @@ paths:
minLength: 1
maxLength: 512
pattern: '^[a-zA-Z0-9_*\-*\.\/]+$'
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
requestBody:
description: Request body is a JsonObject containing ID whose value is the policy ID.
content:
Expand Down Expand Up @@ -2027,6 +2107,14 @@ paths:
minLength: 1
maxLength: 512
pattern: '^[a-zA-Z0-9_*\-*\.\/]+$'
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
responses:
'200':
description: Linked account creation successful
Expand Down Expand Up @@ -2095,6 +2183,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: providerId
in: query
description: Id of the provider for listing their resources
Expand Down Expand Up @@ -2336,6 +2432,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: providerId
in: query
description: ID of the provider for its details. This is an optional parameter
Expand Down Expand Up @@ -2509,6 +2613,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productId
in: query
description: purchases based on productId. Specifying this is optional
Expand Down Expand Up @@ -2947,6 +3059,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: resourceId
in: query
description: ID of the resource for listing products that contain it.
Expand Down Expand Up @@ -3159,6 +3279,14 @@ paths:
type: string
pattern: '^[a-zA-Z0-9\/\@\.]*$'
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productId
in: query
description: product ID for which variants need to be fetched
Expand Down Expand Up @@ -3338,8 +3466,6 @@ paths:
summary: Order
tags:
- Order


responses:
'201':
description: Created
Expand Down Expand Up @@ -3447,6 +3573,14 @@ paths:
required: true
schema:
type: string
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productVariantId
description: ID of the product variant that could obtained from list product variant API
required: true
Expand Down Expand Up @@ -3592,6 +3726,14 @@ paths:
pattern: '^[a-zA-Z0-9_*\-*\.\/]+$'
minLength: 1
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
responses:
'200':
description: Policies have been successfully listed.
Expand Down Expand Up @@ -3659,6 +3801,14 @@ paths:
pattern: '^[a-zA-Z0-9_*\-*\.\/]+$'
minLength: 1
maxLength: 512
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
- name: productVariantId
in: query
description: Id of the resource for its details
Expand Down Expand Up @@ -3855,6 +4005,14 @@ paths:
name: token
required: true
description: DX Auth token to process the request
- name: Authorization
in: header
description: DX Auth Bearer token to process the request
required: false
schema:
type: string
pattern: 'Bearer [a-zA-Z0-9_*\-*\.\/]+$'
maxLength: 512
requestBody:
description: 'Request expects a Order Id, Payment Id and a Payment Signature which will be verified from RazorPay'
content:
Expand Down
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<exec.mainClass>iudx.data.marketplace.deploy.Deployer</exec.mainClass>
<config.file>config.json</config.file>
<flyway-database-postgresql-version>11.1.1</flyway-database-postgresql-version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -299,6 +300,13 @@
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
<version>${flyway-database-postgresql-version}</version>
<scope>runtime</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iudx.data.marketplace.authenticator;
package iudx.data.marketplace.aaaService;

import static iudx.data.marketplace.apiserver.util.Constants.*;
import static iudx.data.marketplace.common.HttpStatusCode.INTERNAL_SERVER_ERROR;
Expand All @@ -9,6 +9,7 @@
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import iudx.data.marketplace.authenticator.model.UserInfo;
import iudx.data.marketplace.policies.User;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -32,11 +33,16 @@ public AuthClient(JsonObject config, WebClient webClient) {
this.authPort = config.getInteger("authPort");
}

public Future<User> fetchUserInfo(JsonObject jsonObject) {
public Future<User> fetchUserInfo(UserInfo userInfo) {
Promise<User> promise = Promise.promise();
String userId = jsonObject.getString(USERID);
String iudxRole = jsonObject.getString(ROLE).toLowerCase();
String resourceServer = jsonObject.getString("aud");
String userId = userInfo.getUserIdAsString();
String iudxRole = userInfo.getRole().getRole().toLowerCase();
String resourceServer = userInfo.getAudience();

LOGGER.debug("User info : {}", userInfo.toString());
LOGGER.debug("authHost : {}", authHost);
LOGGER.debug("authServerSearchPath : {}", authServerSearchPath);
LOGGER.debug("authPort: {}", authPort);

Future<HttpResponse<Buffer>> responseFuture =
client
Expand Down
Loading