2 RedfishCrentialDxe produces the EdkIIRedfishCredentialProtocol for the consumer
3 to get the Redfish credential Info and to restrict Redfish access from UEFI side.
5 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <RedfishCredentialDxe.h>
13 EDKII_REDFISH_CREDENTIAL_PROTOCOL mRedfishCredentialProtocol
= {
14 RedfishCredentialGetAuthInfo
,
15 RedfishCredentialStopService
19 Callback function executed when the ExitBootServices event group is signaled.
21 @param[in] Event Event whose notification function is being invoked.
22 @param[out] Context Pointer to the buffer pass in.
26 RedfishCredentialExitBootServicesEventNotify (
31 LibCredentialExitBootServicesNotify ((EDKII_REDFISH_CREDENTIAL_PROTOCOL
*)Context
);
35 Callback function executed when the EndOfDxe event group is signaled.
37 @param[in] Event Event whose notification function is being invoked.
38 @param[out] Context Pointer to the buffer pass in.
42 RedfishCredentialEndOfDxeEventNotify (
47 LibCredentialEndOfDxeNotify ((EDKII_REDFISH_CREDENTIAL_PROTOCOL
*)Context
);
50 // Close event, so it will not be invoked again.
52 gBS
->CloseEvent (Event
);
56 Retrieve platform's Redfish authentication information.
58 This functions returns the Redfish authentication method together with the user Id and
60 - For AuthMethodNone, the UserId and Password could be used for HTTP header authentication
61 as defined by RFC7235.
62 - For AuthMethodRedfishSession, the UserId and Password could be used for Redfish
63 session login as defined by Redfish API specification (DSP0266).
65 Callers are responsible for and freeing the returned string storage.
67 @param[in] This Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
68 @param[out] AuthMethod Type of Redfish authentication method.
69 @param[out] UserId The pointer to store the returned UserId string.
70 @param[out] Password The pointer to store the returned Password string.
72 @retval EFI_SUCCESS Get the authentication information successfully.
73 @retval EFI_ACCESS_DENIED SecureBoot is disabled after EndOfDxe.
74 @retval EFI_INVALID_PARAMETER This or AuthMethod or UserId or Password is NULL.
75 @retval EFI_OUT_OF_RESOURCES There are not enough memory resources.
76 @retval EFI_UNSUPPORTED Unsupported authentication method is found.
81 RedfishCredentialGetAuthInfo (
82 IN EDKII_REDFISH_CREDENTIAL_PROTOCOL
*This
,
83 OUT EDKII_REDFISH_AUTH_METHOD
*AuthMethod
,
88 if (This
== NULL
|| AuthMethod
== NULL
|| UserId
== NULL
|| Password
== NULL
) {
89 return EFI_INVALID_PARAMETER
;
92 return LibCredentialGetAuthInfo (This
, AuthMethod
, UserId
,Password
);
96 Notify the Redfish service provide to stop provide configuration service to this platform.
98 This function should be called when the platfrom is about to leave the safe environment.
99 It will notify the Redfish service provider to abort all logined session, and prohibit
100 further login with original auth info. GetAuthInfo() will return EFI_UNSUPPORTED once this
101 function is returned.
103 @param[in] This Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
104 @param[in] ServiceStopType Reason of stopping Redfish service.
106 @retval EFI_SUCCESS Service has been stoped successfully.
107 @retval EFI_INVALID_PARAMETER This is NULL or given the worng ServiceStopType.
108 @retval EFI_UNSUPPORTED Not support to stop Redfish service.
109 @retval Others Some error happened.
114 RedfishCredentialStopService (
115 IN EDKII_REDFISH_CREDENTIAL_PROTOCOL
*This
,
116 IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
120 return EFI_INVALID_PARAMETER
;
123 return LibStopRedfishService (This
, ServiceStopType
);
127 Main entry for this driver.
129 @param ImageHandle Image handle this driver.
130 @param SystemTable Pointer to SystemTable.
132 @retval EFI_SUCESS This function always complete successfully.
137 RedfishCredentialDxeDriverEntryPoint (
138 IN EFI_HANDLE ImageHandle
,
139 IN EFI_SYSTEM_TABLE
*SystemTable
144 EFI_EVENT EndOfDxeEvent
;
145 EFI_EVENT ExitBootServiceEvent
;
150 // Install the RedfishCredentialProtocol onto Handle.
152 Status
= gBS
->InstallMultipleProtocolInterfaces (
154 &gEdkIIRedfishCredentialProtocolGuid
,
155 &mRedfishCredentialProtocol
,
158 if (EFI_ERROR (Status
)) {
163 // After EndOfDxe, if SecureBoot is disabled, Redfish Credential Protocol should return
164 // error code to caller to avoid the 3rd code to bypass Redfish Credential Protocol and
165 // retrieve userid/pwd directly. So, here, we create EndOfDxe Event to check SecureBoot
168 Status
= gBS
->CreateEventEx (
171 RedfishCredentialEndOfDxeEventNotify
,
172 (VOID
*)&mRedfishCredentialProtocol
,
173 &gEfiEndOfDxeEventGroupGuid
,
176 if (EFI_ERROR (Status
)) {
181 // After ExitBootServices, Redfish Credential Protocol should stop the service.
182 // So, here, we create ExitBootService Event to stop service.
184 Status
= gBS
->CreateEventEx (
187 RedfishCredentialExitBootServicesEventNotify
,
188 (VOID
*)&mRedfishCredentialProtocol
,
189 &gEfiEventExitBootServicesGuid
,
190 &ExitBootServiceEvent
192 if (EFI_ERROR (Status
)) {
193 gBS
->CloseEvent (EndOfDxeEvent
);
201 gBS
->UninstallMultipleProtocolInterfaces (
203 &gEdkIIRedfishCredentialProtocolGuid
,
204 &mRedfishCredentialProtocol
,