MCPcopy Index your code
hub / github.com/apache/answer / AuthAPIKeyScope

Method AuthAPIKeyScope

internal/base/middleware/auth.go:238–255  ·  view source on GitHub ↗
(ctx *gin.Context, accessToken string)

Source from the content-addressed store, hash-verified

236}
237
238func (am *AuthUserMiddleware) AuthAPIKeyScope(ctx *gin.Context, accessToken string) (apiHaveNoScope bool) {
239 if !strings.HasPrefix(accessToken, "sk_") {
240 return false
241 }
242 var err error
243 pass, err := am.authService.AuthAPIKey(ctx, ctx.Request.Method == "GET", accessToken)
244 if err != nil {
245 handler.HandleResponse(ctx, errors.Forbidden(reason.ForbiddenError), nil)
246 ctx.Abort()
247 return true
248 }
249 if !pass {
250 handler.HandleResponse(ctx, errors.Forbidden(reason.ForbiddenError), nil)
251 ctx.Abort()
252 return true
253 }
254 return false
255}
256
257func ShowIndexPage(ctx *gin.Context) {
258 ctx.Header("content-type", "text/html;charset=utf-8")

Calls 2

HandleResponseFunction · 0.92
AuthAPIKeyMethod · 0.45

Tested by

no test coverage detected