-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add rollup verification (#329)
* Feature: add rollup verification * Fix: change verification status * Add admin middleware * Add some useful enpoints
- Loading branch information
1 parent
2a5cb77
commit 53da19b
Showing
23 changed files
with
530 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io> | ||
// SPDX-License-Identifier: MIT | ||
|
||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/celenium-io/celestia-indexer/cmd/api/handler" | ||
"github.com/celenium-io/celestia-indexer/internal/storage" | ||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
var accessDeniedErr = echo.Map{ | ||
"error": "access denied", | ||
} | ||
|
||
func AdminMiddleware() echo.MiddlewareFunc { | ||
return checkOnAdminPermission | ||
} | ||
|
||
func checkOnAdminPermission(next echo.HandlerFunc) echo.HandlerFunc { | ||
return func(ctx echo.Context) error { | ||
val := ctx.Get(handler.ApiKeyName) | ||
apiKey, ok := val.(storage.ApiKey) | ||
if !ok { | ||
return ctx.JSON(http.StatusForbidden, accessDeniedErr) | ||
} | ||
if !apiKey.Admin { | ||
return ctx.JSON(http.StatusForbidden, accessDeniedErr) | ||
} | ||
return next(ctx) | ||
} | ||
} |
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
Oops, something went wrong.