Added userinfo endpoint to validate basic auth (#1131)
* Added userinfo endpoint to validate basic auth * Fixed the bean exception for failing tests * Added tests for userinfo endpoint with basic auth * Added the missing license header Signed-off-by: Anand kumar <anand.kumar@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.auth;
|
||||
|
||||
/**
|
||||
* A json annotated rest model for Userinfo to RESTful API representation.
|
||||
*
|
||||
*/
|
||||
public class MgmtUserInfo {
|
||||
|
||||
private String username;
|
||||
private String tenant;
|
||||
|
||||
/**
|
||||
* @return Username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username Username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tenant
|
||||
*/
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenant Tenant
|
||||
*/
|
||||
public void setTenant(String tenant) {
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.rest.api;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.auth.MgmtUserInfo;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* Api for handling basic auth user validation
|
||||
*/
|
||||
@RequestMapping(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)
|
||||
public interface MgmtBasicAuthRestApi {
|
||||
/**
|
||||
* Handles the GET request of basic auth.
|
||||
*
|
||||
* @return the userinfo with status OK.
|
||||
*/
|
||||
@GetMapping(produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<MgmtUserInfo> validateBasicAuth();
|
||||
}
|
||||
@@ -233,6 +233,11 @@ public final class MgmtRestConstants {
|
||||
|
||||
public static final String DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES = "mandatorymoduletypes";
|
||||
|
||||
/**
|
||||
* The basic authentication validation mapping
|
||||
*/
|
||||
public static final String AUTH_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/userinfo";
|
||||
|
||||
// constant class, private constructor.
|
||||
private MgmtRestConstants() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user