-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Define SecretStoreAuth in separate file
Define SecretStoreAuthenticationHandlerFunc in separate file Signed-off-by: Lindsey Cheng <[email protected]>
- Loading branch information
1 parent
d68de5a
commit 46f501e
Showing
11 changed files
with
54 additions
and
58 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Copyright (C) 2025 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/interfaces" | ||
"github.com/edgexfoundry/go-mod-core-contracts/v4/clients/logger" | ||
|
||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
// SecretStoreAuthenticationHandlerFunc verifies the JWT with a OpenBao-based JWT authentication check | ||
func SecretStoreAuthenticationHandlerFunc(secretProvider interfaces.SecretProviderExt, lc logger.LoggingClient, token string, c echo.Context) error { | ||
r := c.Request() | ||
w := c.Response() | ||
|
||
validToken, err := secretProvider.IsJWTValid(token) | ||
if err != nil { | ||
lc.Errorf("Error checking JWT validity by the secret provider: %v ", err) | ||
// set Response.Committed to true in order to rewrite the status code | ||
w.Committed = false | ||
return echo.NewHTTPError(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) | ||
} else if !validToken { | ||
lc.Warnf("Request to '%s' UNAUTHORIZED", r.URL.Path) | ||
// set Response.Committed to true in order to rewrite the status code | ||
w.Committed = false | ||
return echo.NewHTTPError(http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized)) | ||
} | ||
lc.Debugf("Request to '%s' authorized", r.URL.Path) | ||
return nil | ||
} |
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,9 @@ | ||
// | ||
// Copyright (C) 2025 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package handlers | ||
|
||
// openBaoIssuer defines the issuer if JWT was issued from OpenBao | ||
const openBaoIssuer = "/v1/identity/oidc" |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright (C) 2024 IOTech Ltd | ||
// Copyright (C) 2025 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright (C) 2024 IOTech Ltd | ||
// Copyright (C) 2025 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright (C) 2024 IOTech Ltd | ||
// Copyright (C) 2025 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright (C) 2024 IOTech Ltd | ||
// Copyright (C) 2025 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|