feat: add oauth token validity verification

This commit is contained in:
2024-11-08 12:03:52 +01:00
parent d6e7791cb4
commit bd20895306
12 changed files with 326 additions and 119 deletions

View File

@@ -16,7 +16,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import (
"encoding/json"
"fmt"
"github.com/jkaninda/goma-gateway/pkg/logger"
"net/http"
@@ -44,18 +43,12 @@ func (proxyRoute ProxyRoute) ProxyHandler() http.HandlerFunc {
w.Header().Set(accessControlAllowOrigin, r.Header.Get("Origin"))
}
}
// Parse the target backend URL
targetURL, err := url.Parse(proxyRoute.destination)
if err != nil {
logger.Error("Error parsing backend URL: %s", err)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusInternalServerError)
err := json.NewEncoder(w).Encode(ErrorResponse{
Message: "Internal server error",
Code: http.StatusInternalServerError,
Success: false,
})
_, err := w.Write([]byte("Internal Server Error"))
if err != nil {
return
}