Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 0 additions & 93 deletions agent_api_rest/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,99 +366,6 @@ paths:
description: Authorization Request not found

# Issuance endpoints
/v0/credential-configurations:
post:
tags:
- Issuance
summary: Create a new Credential Configuration
description: Creates a new credential configuration for the issuer
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
credential_configuration_id:
type: string
example: w3c_vc_credential
format:
type: string
example: jwt_vc_json
credential_definition:
type: object
properties:
type:
type: array
items:
type: string
example: VerifiableCredential
example:
- VerifiableCredential
display:
type: array
items:
type: object
properties:
locale:
type: string
example: en
logo:
type: object
properties:
alt_text:
type: string
example: UniCore Logo
uri:
type: string
example: https://impierce.com/images/logo-blue.png
name:
type: string
example: Identity Credential
example:
- locale: en
logo:
alt_text: UniCore Logo
uri: https://impierce.com/images/logo-blue.png
name: Identity Credential
required:
- credential_configuration_id
- format
- credential_definition
examples:
openbadgesv3_credential_configurations:
summary: Open Badges 3.0
value:
credential_configuration_id: openbadge_credential
credential_definition:
type:
- VerifiableCredential
- OpenBadgeCredential
display:
- locale: en
logo:
alt_text: UniCore Logo
uri: https://impierce.com/images/logo-blue.png
name: Identity Credential
format: jwt_vc_json
w3c_vc_credential_configurations:
summary: W3C VC Data Model
value:
credential_configuration_id: w3c_vc_credential
credential_definition:
type:
- VerifiableCredential
display:
- locale: en
logo:
alt_text: UniCore Logo
uri: https://impierce.com/images/logo-blue.png
name: Identity Credential
format: jwt_vc_json
responses:
"200":
description: A Credential Configuration has been successfully added to the Credential Issuer Metadata

/v0/offers/send:
post:
summary: Send an offer
Expand Down
27 changes: 0 additions & 27 deletions agent_api_rest/postman/ssi-agent.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -430,33 +430,6 @@
}
},
"response": []
},
{
"name": "Create a new Credential Configuration",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"credential_configuration_id\": \"002\",\n \"format\": \"jwt_vc_json\",\n \"credential_definition\": {\n \"type\": [\"VerifiableCredential\"]\n },\n \"display\": [\n {\n \"name\": \"Verifiable Credential\",\n \"locale\": \"en\",\n \"logo\": {\n \"uri\": \"https://www.impierce.com/external/impierce-logo.png\",\n \"alt_text\": \"Impierce Logo\"\n }\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HOST}}/v0/credential-configurations",
"host": [
"{{HOST}}"
],
"path": [
"v0",
"credential-configurations"
]
}
},
"response": []
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use axum::{
};
use http::header;
use oid4vci::wallet::AuthorizationRequestByReference;
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn authorize(
State(state): State<AuthorizationState>,
State(state): State<Arc<AuthorizationState>>,
Query(authorization_request): Query<AuthorizationRequestByReference>,
) -> Result<Response, PublicError> {
match OAuth2AuthorizationService::handle_authorization_request(&state, authorization_request)
Expand Down Expand Up @@ -109,7 +110,7 @@ pub mod tests {
#[serial_test::serial]
#[tokio::test]
async fn test_authorization_endpoint() {
let issuance_state = issuance_state(&InMemory, Service::default(), Default::default()).await;
let issuance_state = Arc::new(issuance_state(&InMemory, Service::default(), Default::default()).await);

agent_issuance::state::initialize(&issuance_state).await.unwrap();

Expand All @@ -120,7 +121,8 @@ pub mod tests {
let AuthorizationCode { issuer_state, .. } = authorization_code.unwrap();
let issuer_state = issuer_state.unwrap();

let authorization_state = authorization_state(&InMemory, Service::default(), Default::default()).await;
let authorization_state =
Arc::new(authorization_state(&InMemory, Service::default(), Default::default()).await);
agent_authorization::state::initialize(&authorization_state)
.await
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ use axum::{
};
use http::{header, StatusCode};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use tracing::info;

#[axum_macros::debug_handler]
pub(crate) async fn get_consent(
State(state): State<AuthorizationState>,
State(state): State<Arc<AuthorizationState>>,
StringifiedQuery(GetConsentQuery { request_uri }): StringifiedQuery<GetConsentQuery>,
) -> Result<Response, PublicError> {
let ConsentPageViewModel {
Expand Down Expand Up @@ -47,7 +48,7 @@ pub struct ConsentForm {

// TODO: investigate replay attacks as described here: https://github.com/impierce/ssi-agent/issues/241
pub async fn post_consent(
State(state): State<AuthorizationState>,
State(state): State<Arc<AuthorizationState>>,
Form(ConsentForm {
client_id,
request_uri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ use axum::{
response::{IntoResponse, Response},
};
use oid4vci::authorization_request::AuthorizationRequest;
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn par(
State(state): State<AuthorizationState>,
State(state): State<Arc<AuthorizationState>>,
StringifiedForm(pushed_authorization_request): StringifiedForm<AuthorizationRequest>,
) -> Result<Response, PublicError> {
let pushed_authorization_response =
Expand Down Expand Up @@ -103,7 +104,7 @@ pub mod tests {
#[serial_test::serial]
#[tokio::test]
async fn test_pushed_authorization_request_endpoint() {
let issuance_state = issuance_state(&InMemory, Service::default(), Default::default()).await;
let issuance_state = Arc::new(issuance_state(&InMemory, Service::default(), Default::default()).await);

agent_issuance::state::initialize(&issuance_state).await.unwrap();

Expand All @@ -114,7 +115,8 @@ pub mod tests {
let AuthorizationCode { issuer_state, .. } = authorization_code.unwrap();
let issuer_state = issuer_state.unwrap();

let authorization_state = authorization_state(&InMemory, Service::default(), Default::default()).await;
let authorization_state =
Arc::new(authorization_state(&InMemory, Service::default(), Default::default()).await);
agent_authorization::state::initialize(&authorization_state)
.await
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ use axum::{
Form,
};
use oid4vci::token_request::TokenRequest;
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn token(
State((authorization_state, issuance_state)): State<(AuthorizationState, IssuanceState)>,
State((authorization_state, issuance_state)): State<(Arc<AuthorizationState>, Arc<IssuanceState>)>,
Form(token_request): Form<TokenRequest>,
) -> Result<Response, PublicError> {
let token_response =
Expand Down Expand Up @@ -138,7 +139,7 @@ pub mod tests {
#[serial_test::serial]
#[tokio::test]
async fn test_token_endpoint(#[case] is_pre_authorized: bool) {
let issuance_state = issuance_state(&InMemory, Service::default(), Default::default()).await;
let issuance_state = Arc::new(issuance_state(&InMemory, Service::default(), Default::default()).await);

agent_issuance::state::initialize(&issuance_state).await.unwrap();

Expand All @@ -153,7 +154,8 @@ pub mod tests {
credentials(&mut app, &credential_configuration_id).await;
let grants = offers(&mut app, &credential_configuration_id).await.unwrap();

let authorization_state = authorization_state(&InMemory, Service::default(), Default::default()).await;
let authorization_state =
Arc::new(authorization_state(&InMemory, Service::default(), Default::default()).await);

agent_authorization::state::initialize(&authorization_state)
.await
Expand Down
3 changes: 2 additions & 1 deletion agent_api_rest/src/authorization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use agent_issuance::state::IssuanceState;
use authorization_server::{authorize::authorize, par::par, token::token};
use axum::routing::get;
use axum::{routing::post, Router};
use std::sync::Arc;

pub fn router((authorization_state, issuance_state): (AuthorizationState, IssuanceState)) -> Router {
pub fn router((authorization_state, issuance_state): (Arc<AuthorizationState>, Arc<IssuanceState>)) -> Router {
Router::new()
.nest(API_VERSION, Router::new())
.route("/auth/consent", get(get_consent).post(post_consent))
Expand Down
7 changes: 4 additions & 3 deletions agent_api_rest/src/holder/holder/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use http_api_problem::ApiError;
use hyper::StatusCode;
use identity_credential::credential::Jwt;
use serde::{Deserialize, Serialize};
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn credentials(State(state): State<HolderState>) -> Result<Response, ApiError> {
pub(crate) async fn credentials(State(state): State<Arc<HolderState>>) -> Result<Response, ApiError> {
let all_credentials = query_handler("all_holder_credentials", &state.query.all_holder_credentials)
.await?
.map(|all_credentials_view| all_credentials_view.credentials.into_values().collect::<Vec<_>>())
Expand All @@ -28,7 +29,7 @@ pub struct HolderCredentialsEndpointRequest {

#[axum_macros::debug_handler]
pub(crate) async fn post_credentials(
State(state): State<HolderState>,
State(state): State<Arc<HolderState>>,
Json(HolderCredentialsEndpointRequest { credential }): Json<HolderCredentialsEndpointRequest>,
) -> Result<Response, ApiError> {
let holder_credential_id = uuid::Uuid::new_v4().to_string();
Expand All @@ -50,7 +51,7 @@ pub(crate) async fn post_credentials(

#[axum_macros::debug_handler]
pub(crate) async fn credential(
State(state): State<HolderState>,
State(state): State<Arc<HolderState>>,
Path(holder_credential_id): Path<String>,
) -> Result<Response, ApiError> {
query_handler(&holder_credential_id, &state.query.holder_credential)
Expand Down
3 changes: 2 additions & 1 deletion agent_api_rest/src/holder/holder/offers/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ use axum::{
};
use http_api_problem::ApiError;
use hyper::StatusCode;
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn accept(
State(state): State<HolderState>,
State(state): State<Arc<HolderState>>,
Path(received_offer_id): Path<String>,
) -> Result<Response, ApiError> {
// TODO: General note that also applies to other endpoints: currently we are using Application Layer logic in the
Expand Down
5 changes: 3 additions & 2 deletions agent_api_rest/src/holder/holder/offers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use axum::{
};
use http_api_problem::ApiError;
use hyper::StatusCode;
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn offers(State(state): State<HolderState>) -> Result<Response, ApiError> {
pub(crate) async fn offers(State(state): State<Arc<HolderState>>) -> Result<Response, ApiError> {
let all_received_offers = query_handler("all_received_offers", &state.query.all_received_offers)
.await?
.map(|all_received_offers_view| {
Expand All @@ -28,7 +29,7 @@ pub(crate) async fn offers(State(state): State<HolderState>) -> Result<Response,

#[axum_macros::debug_handler]
pub(crate) async fn offer(
State(state): State<HolderState>,
State(state): State<Arc<HolderState>>,
Path(received_offer_id): Path<String>,
) -> Result<Response, ApiError> {
query_handler(&received_offer_id, &state.query.received_offer)
Expand Down
3 changes: 2 additions & 1 deletion agent_api_rest/src/holder/holder/offers/reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use axum::{
};
use http_api_problem::ApiError;
use hyper::StatusCode;
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn reject(
State(state): State<HolderState>,
State(state): State<Arc<HolderState>>,
Path(received_offer_id): Path<String>,
) -> Result<Response, ApiError> {
let command = OfferCommand::RejectCredentialOffer {
Expand Down
7 changes: 4 additions & 3 deletions agent_api_rest/src/holder/holder/presentations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ use axum::{
use http_api_problem::ApiError;
use hyper::StatusCode;
use serde::{Deserialize, Serialize};
use std::sync::Arc;

#[axum_macros::debug_handler]
pub(crate) async fn get_presentations(State(state): State<HolderState>) -> Result<Response, ApiError> {
pub(crate) async fn get_presentations(State(state): State<Arc<HolderState>>) -> Result<Response, ApiError> {
let all_presentations = query_handler("all_presentations", &state.query.all_presentations)
.await?
.map(|all_presentations_view| all_presentations_view.presentations.into_values().collect::<Vec<_>>())
Expand All @@ -25,7 +26,7 @@ pub(crate) async fn get_presentations(State(state): State<HolderState>) -> Resul

#[axum_macros::debug_handler]
pub(crate) async fn presentation(
State(state): State<HolderState>,
State(state): State<Arc<HolderState>>,
Path(presentation_id): Path<String>,
) -> Result<Response, ApiError> {
query_handler(&presentation_id, &state.query.presentation)
Expand All @@ -42,7 +43,7 @@ pub struct PresentationsEndpointRequest {

#[axum_macros::debug_handler]
pub(crate) async fn post_presentations(
State(state): State<HolderState>,
State(state): State<Arc<HolderState>>,
Json(PresentationsEndpointRequest { credential_ids }): Json<PresentationsEndpointRequest>,
) -> Result<Response, ApiError> {
let mut credentials = vec![];
Expand Down
Loading
Loading