Skip to content

Commit

Permalink
Merge pull request #259 from aleksandra-bel/feature/scopes-matching
Browse files Browse the repository at this point in the history
Feature/scopes matching
  • Loading branch information
borisrizov-zf authored Mar 1, 2024
2 parents 0232cd9 + 4b3c764 commit e500c4b
Show file tree
Hide file tree
Showing 23 changed files with 802 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;

public class DidDocumentControllerApiDocs {

Expand Down Expand Up @@ -72,7 +73,7 @@ public class DidDocumentControllerApiDocs {
""")
})
}) })
@Operation(description = "Resolve the DID document for a given DID or BPN", summary = "Resolve DID Document")
@Operation(description = "Resolve the DID document for a given DID or BPN", summary = "Resolve DID Document", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface GetDidDocumentApiDocs {
}

Expand Down Expand Up @@ -135,7 +136,7 @@ public class DidDocumentControllerApiDocs {
})
})
})
@Operation(description = "Resolve the DID document for a given BPN", summary = "Resolve DID Document")
@Operation(description = "Resolve the DID document for a given BPN", summary = "Resolve DID Document", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface GetDidResolveApiDocs {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;

public class HoldersCredentialControllerApiDocs {

Expand Down Expand Up @@ -148,7 +149,7 @@ public class HoldersCredentialControllerApiDocs {
""")
})
}) })
@Operation(description = "Permission: **view_wallets** OR **view_wallet** (The BPN of holderIdentifier must equal BPN of caller)\n\n Search verifiable credentials with filter criteria", summary = "Query Verifiable Credentials")
@Operation(description = "Permission: **view_wallets** OR **view_wallet** (The BPN of holderIdentifier must equal BPN of caller)\n\n Search verifiable credentials with filter criteria", summary = "Query Verifiable Credentials", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface GetCredentialsApiDocs {
}

Expand Down Expand Up @@ -278,7 +279,7 @@ public class HoldersCredentialControllerApiDocs {
}
"""))
})
@Operation(summary = "Issue Verifiable Credential", description = "Permission: **update_wallets** OR **update_wallet** (The BPN of the issuer of the Verifiable Credential must equal BPN of caller)\nIssue a verifiable credential with a given issuer DID")
@Operation(summary = "Issue Verifiable Credential", description = "Permission: **update_wallets** OR **update_wallet** (The BPN of the issuer of the Verifiable Credential must equal BPN of caller)\nIssue a verifiable credential with a given issuer DID", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface IssueCredentialApiDoc {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;

public class IssuersCredentialControllerApiDocs {
Expand Down Expand Up @@ -192,7 +193,7 @@ public class IssuersCredentialControllerApiDocs {
})
}),
})
@Operation(description = "Permission: **view_wallets** (The BPN of holderIdentifier must equal BPN of caller)\n\n Search verifiable credentials with filter criteria", summary = "Query Verifiable Credentials")
@Operation(description = "Permission: **view_wallets** (The BPN of holderIdentifier must equal BPN of caller)\n\n Search verifiable credentials with filter criteria", summary = "Query Verifiable Credentials", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface GetCredentialsApiDocs {
}

Expand Down Expand Up @@ -315,7 +316,7 @@ public class IssuersCredentialControllerApiDocs {
""")
})
}) })
@Operation(summary = "Issue a Membership Verifiable Credential with base wallet issuer", description = "Permission: **update_wallets** (The BPN of base wallet must equal BPN of caller)\n\n Issue a verifiable credential by base wallet")
@Operation(summary = "Issue a Membership Verifiable Credential with base wallet issuer", description = "Permission: **update_wallets** (The BPN of base wallet must equal BPN of caller)\n\n Issue a verifiable credential by base wallet", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface IssueMembershipCredentialApiDoc {
}

Expand Down Expand Up @@ -447,7 +448,7 @@ public class IssuersCredentialControllerApiDocs {
})
})
})
@Operation(summary = "Issue a Dismantler Verifiable Credential with base wallet issuer", description = "Permission: **update_wallets** (The BPN of base wallet must equal BPN of caller)\n\n Issue a verifiable credential by base wallet")
@Operation(summary = "Issue a Dismantler Verifiable Credential with base wallet issuer", description = "Permission: **update_wallets** (The BPN of base wallet must equal BPN of caller)\n\n Issue a verifiable credential by base wallet", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface IssueDismantlerCredentialApiDoc {
}

Expand Down Expand Up @@ -515,7 +516,7 @@ public class IssuersCredentialControllerApiDocs {
})
})
@Tag(name = API_TAG_VERIFIABLE_CREDENTIAL_ISSUER)
@Operation(summary = "Issue a Use Case Verifiable Credential with base wallet issuer", description = "Permission: **update_wallets** (The BPN of base wallet must equal BPN of caller)\n\n Issue a verifiable credential by base wallet")
@Operation(summary = "Issue a Use Case Verifiable Credential with base wallet issuer", description = "Permission: **update_wallets** (The BPN of base wallet must equal BPN of caller)\n\n Issue a verifiable credential by base wallet", security = { @SecurityRequirement(name = "Authenticate using access_token") })
@ApiResponses(value = {
@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
@Content(examples = {}) }),
Expand Down Expand Up @@ -943,7 +944,7 @@ public class IssuersCredentialControllerApiDocs {
""")
})
}) })
@Operation(summary = "Validate Verifiable Credentials", description = "Permission: **view_wallets** OR **view_wallet** \n\n Validate Verifiable Credentials")
@Operation(summary = "Validate Verifiable Credentials", description = "Permission: **view_wallets** OR **view_wallet** \n\n Validate Verifiable Credentials", security = { @SecurityRequirement(name = "Authenticate using access_token") })
@RequestBody(content = {
@Content(examples = @ExampleObject("""
{
Expand Down Expand Up @@ -1074,7 +1075,7 @@ public class IssuersCredentialControllerApiDocs {
""")
})
}) })
@Operation(summary = "Issue Verifiable Credential", description = "Permission: **update_wallets** (The BPN of the base wallet must equal BPN of caller)\nIssue a verifiable credential with a given issuer DID")
@Operation(summary = "Issue Verifiable Credential", description = "Permission: **update_wallets** (The BPN of the base wallet must equal BPN of caller)\nIssue a verifiable credential with a given issuer DID", security = { @SecurityRequirement(name = "Authenticate using access_token") })
@RequestBody(content = {
@Content(examples = @ExampleObject("""
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package org.eclipse.tractusx.managedidentitywallets.apidocs;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

public class PresentationControllerApiDocs {
public static final String API_TAG_VERIFIABLE_PRESENTATIONS_GENERATION = "Verifiable Presentations - Generation";
public static final String API_TAG_VERIFIABLE_PRESENTATIONS_VALIDATION = "Verifiable Presentations - Validation";

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Tag(name = API_TAG_VERIFIABLE_PRESENTATIONS_GENERATION)
@Operation(summary = "Create Verifiable Presentation", description = "Permission: **update_wallets** OR **update_wallet** (The BPN of the issuer of the Verifiable Presentation must equal to BPN of caller) \n\n Create a verifiable presentation from a list of verifiable credentials, signed by the holder")
@Operation(summary = "Create Verifiable Presentation", description = "Permission: **update_wallets** OR **update_wallet** (The BPN of the issuer of the Verifiable Presentation must equal to BPN of caller) \n\n Create a verifiable presentation from a list of verifiable credentials, signed by the holder", security = { @SecurityRequirement(name = "Authenticate using access_token") })
@ApiResponses(value = {

@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
Expand Down Expand Up @@ -155,7 +156,7 @@ public class PresentationControllerApiDocs {
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Tag(name = API_TAG_VERIFIABLE_PRESENTATIONS_VALIDATION)
@Operation(summary = "Validate Verifiable Presentation", description = "Permission: **view_wallets** OR **view_wallet** \n\n Validate Verifiable Presentation with all included credentials")
@Operation(summary = "Validate Verifiable Presentation", description = "Permission: **view_wallets** OR **view_wallet** \n\n Validate Verifiable Presentation with all included credentials", security = { @SecurityRequirement(name = "Authenticate using access_token") })
@ApiResponses(value = {
@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
@Content(examples = {}) }),
Expand Down Expand Up @@ -286,4 +287,100 @@ public class PresentationControllerApiDocs {
public @interface PostVerifiablePresentationValidationApiDocs {
}

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Tag(name = API_TAG_VERIFIABLE_PRESENTATIONS_GENERATION)
@Operation(summary = "Create Verifiable Presentation", description = "Create a verifiable presentation for the verifiable credential types listed in STS token", security = { @SecurityRequirement(name = "sts_token") })
@ApiResponses(value = {
@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "403", description = "The request could not be completed due to a forbidden scope value", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "500", description = "Any other internal server error", content = {
@Content(examples = {
@ExampleObject(name = "Internal server error", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 500,
"detail": "Error Details",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
}) }),
@ApiResponse(responseCode = "404", description = "One or more of the requested verifiable credential types were not found", content = {
@Content(examples = {
@ExampleObject(name = "One or more of the requested verifiable credential types were not found", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 404,
"detail": "Verifiable credential types that were not found",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
}) }),
@ApiResponse(responseCode = "200", description = "Verifiable Presentation", content = {
@Content(examples = {
@ExampleObject(name = "VP as Json-LD", value = """
{
"vp": {
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"id": "did:web:localhost:BPNL000000000000#b2e69e47-95f3-48ff-af30-eaaab36431d5",
"type": [
"VerifiablePresentation"
],
"verifiableCredential": [
{
"id": "did:web:localhost:BPNL000000000000#f73e3631-ba87-4a03-bea3-b28700056879",
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://catenax-ng.github.io/product-core-schemas/businessPartnerData.json",
"https://w3id.org/security/suites/jws-2020/v1"
],
"type": [
"VerifiableCredential",
"BpnCredential"
],
"issuer": "did:web:localhost:BPNL000000000000",
"expirationDate": "2024-12-31T18:30:00Z",
"issuanceDate": "2023-07-19T09:11:34Z",
"credentialSubject": [
{
"bpn": "BPNL000000000000",
"id": "did:web:localhost:BPNL000000000000",
"type": "BpnCredential"
}
],
"proof": {
"created": "2023-07-19T09:11:39Z",
"jws": "eyJhbGciOiJFZERTQSJ9..fdn2qU85auOltdHDLdHI7sJVV1ZPdftpiXd_ndXN0dFgSDWiIrScdD03wtvKLq_H-shQWfh2RYeMmrlEzAhfDw",
"proofPurpose": "proofPurpose",
"type": "JsonWebSignature2020",
"verificationMethod": "did:web:localhost:BPNL000000000000#"
}
}
]
}
}
"""),
@ExampleObject(name = "VP as JWT", value = """
{
"vp": "eyJraWQiOiJkaWQ6d2ViOmxvY2FsaG9zdDpCUE5MMDAwMDAwMDAwMDAwIiwidHlwIjoiSldUIiwiYWxnIjoiRWREU0EifQ.eyJzdWIiOiJkaWQ6d2ViOmxvY2FsaG9zdDpCUE5MMDAwMDAwMDAwMDAwIiwiYXVkIjoic21hcnQiLCJpc3MiOiJkaWQ6d2ViOmxvY2FsaG9zdDpC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I6Ikpzb25XZWJTaWduYXR1cmUyMDIwIiwidmVyaWZpY2F0aW9uTWV0aG9kIjoiZGlkOndlYjpsb2NhbGhvc3Q6QlBOTDAwMDAwMDAwMDAwMCMiLCJjcmVhdGVkIjoiMjAyMy0wNy0xOVQwOToxMTozOVoiLCJqd3MiOiJleUpoYkdjaU9pSkZaRVJUUVNKOS4uZmRuMnFVODVhdU9sdGRIRExkSEk3c0pWVjFaUGRmdHBpWGRfbmRYTjBkRmdTRFdpSXJTY2REMDN3dHZLTHFfSC1zaFFXZmgyUlllTW1ybEV6QWhmRHcifX19LCJleHAiOjE2ODk4MzQ4MDUsImp0aSI6ImIwODYzOWZiLWQ5MWEtNGUwZS1iNmY4LTYzYjdhMzQ1ZTRhZiJ9.80x0AB-OauefdeZfx1cwhitdVKRvCRFeFzYwU73DL7y4w34vu6BdfHWLBGjkwELxkQEoFfiTPOqtuyqhtsyDBg"
}
""")
})
})
})
public @interface GetVerifiablePresentationIATPApiDocs {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirements;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -37,6 +38,7 @@ public class SecureTokenControllerApiDoc {

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@SecurityRequirements
@RequestBody(content = {
@Content(examples = {
@ExampleObject(name = "Request Secure Token using Scopes", value = """
Expand Down
Loading

0 comments on commit e500c4b

Please sign in to comment.