-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/develop' into issues/merge-ups…
…tream
- Loading branch information
Showing
5 changed files
with
188 additions
and
5 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...pp/enrollmentserver/api/model/enrollment/request/OidcApplicationConfigurationRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* PowerAuth Enrollment Server | ||
* Copyright (C) 2024 Wultra s.r.o. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.wultra.app.enrollmentserver.api.model.enrollment.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.Data; | ||
|
||
/** | ||
* Request object for OIDC application configuration. | ||
* | ||
* @author Lubos Racansky, [email protected] | ||
*/ | ||
@Data | ||
public class OidcApplicationConfigurationRequest { | ||
|
||
@NotBlank | ||
private String providerId; | ||
} |
42 changes: 42 additions & 0 deletions
42
.../enrollmentserver/api/model/enrollment/response/OidcApplicationConfigurationResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* PowerAuth Enrollment Server | ||
* Copyright (C) 2024 Wultra s.r.o. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.wultra.app.enrollmentserver.api.model.enrollment.response; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* Response object for OIDC application configuration. | ||
* | ||
* @author Lubos Racansky, [email protected] | ||
*/ | ||
@Data | ||
public class OidcApplicationConfigurationResponse { | ||
|
||
private String providerId; | ||
private String clientId; | ||
private String scopes; | ||
private String authorizeUri; | ||
private String redirectUri; | ||
|
||
/** | ||
* A hint for the mobile application whether to user PKCE. | ||
* If set to {@code true}, {@code codeVerifier} must be present in identity attributes during create activation step. | ||
*/ | ||
private boolean pkceEnabled; | ||
|
||
} |
95 changes: 95 additions & 0 deletions
95
...va/com/wultra/app/enrollmentserver/controller/api/ApplicationConfigurationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* PowerAuth Enrollment Server | ||
* Copyright (C) 2024 Wultra s.r.o. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.wultra.app.enrollmentserver.controller.api; | ||
|
||
import com.wultra.app.enrollmentserver.api.model.enrollment.request.OidcApplicationConfigurationRequest; | ||
import com.wultra.app.enrollmentserver.api.model.enrollment.response.OidcApplicationConfigurationResponse; | ||
import io.getlime.core.rest.model.base.response.ObjectResponse; | ||
import io.getlime.security.powerauth.rest.api.spring.annotation.EncryptedRequestBody; | ||
import io.getlime.security.powerauth.rest.api.spring.annotation.PowerAuthEncryption; | ||
import io.getlime.security.powerauth.rest.api.spring.encryption.EncryptionContext; | ||
import io.getlime.security.powerauth.rest.api.spring.encryption.EncryptionScope; | ||
import io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthApplicationConfigurationException; | ||
import io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthEncryptionException; | ||
import io.getlime.security.powerauth.rest.api.spring.service.oidc.OidcApplicationConfiguration; | ||
import io.getlime.security.powerauth.rest.api.spring.service.oidc.OidcApplicationConfigurationService; | ||
import io.getlime.security.powerauth.rest.api.spring.service.oidc.OidcConfigurationQuery; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* Controller that provides application configuration. | ||
* | ||
* @author Lubos Racansky, [email protected] | ||
*/ | ||
@RestController | ||
@RequestMapping("/api/config") | ||
@Slf4j | ||
@AllArgsConstructor | ||
public class ApplicationConfigurationController { | ||
|
||
private OidcApplicationConfigurationService oidcApplicationConfigurationService; | ||
|
||
/** | ||
* Fetch OIDC application configuration. | ||
* | ||
* @param request Request OIDC application configuration. | ||
* @param encryptionContext PowerAuth ECIES encryption context. | ||
* @return OIDC application configuration. | ||
* @throws PowerAuthApplicationConfigurationException In case there is an error while fetching claims. | ||
* @throws PowerAuthEncryptionException In case of failed encryption. | ||
*/ | ||
@PowerAuthEncryption(scope = EncryptionScope.APPLICATION_SCOPE) | ||
@PostMapping("oidc") | ||
@Operation( | ||
summary = "Fetch OIDC application configuration.", | ||
description = "Fetch OIDC application configuration." | ||
) | ||
public ObjectResponse<OidcApplicationConfigurationResponse> fetchOidcConfiguration( | ||
@EncryptedRequestBody OidcApplicationConfigurationRequest request, | ||
@Parameter(hidden = true) EncryptionContext encryptionContext) throws PowerAuthEncryptionException, PowerAuthApplicationConfigurationException { | ||
|
||
if (encryptionContext == null) { | ||
logger.error("Encryption failed"); | ||
throw new PowerAuthEncryptionException("Encryption failed"); | ||
} | ||
|
||
final OidcApplicationConfiguration oidcApplicationConfiguration = oidcApplicationConfigurationService.fetchOidcApplicationConfiguration(OidcConfigurationQuery.builder() | ||
.providerId(request.getProviderId()) | ||
.applicationKey(encryptionContext.getApplicationKey()) | ||
.build()); | ||
final OidcApplicationConfigurationResponse result = convert(oidcApplicationConfiguration); | ||
return new ObjectResponse<>(result); | ||
} | ||
|
||
private static OidcApplicationConfigurationResponse convert(final OidcApplicationConfiguration source) { | ||
final OidcApplicationConfigurationResponse target = new OidcApplicationConfigurationResponse(); | ||
target.setClientId(source.getClientId()); | ||
target.setAuthorizeUri(source.getAuthorizeUri()); | ||
target.setScopes(source.getScopes()); | ||
target.setRedirectUri(source.getRedirectUri()); | ||
target.setProviderId(source.getProviderId()); | ||
target.setPkceEnabled(source.isPkceEnabled()); | ||
return target; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters