<commit_before>package minion

import (
	"net/http"

	jwt "github.com/dgrijalva/jwt-go"
)

// CreateJWTToken creates a jwt token with the given secret
func CreateJWTToken(claims map[string]interface{}) (string, error) {
	_, tokenString, err := tokenAuth.Encode(claims)

	return tokenString, err
}

// Authenticator ...
func (c *Context) Authenticator(next http.Handler) http.Handler {
	return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		unauthenticated := false

		for _, path := range c.Engine.options.UnauthenticatedRoutes {
			if req.URL.Path == path {
				unauthenticated = true
			}
		}

		if !unauthenticated {
			errResp := struct {
				Code int    `json:"status"`
				Msg  string `json:"message"`
			}{
				http.StatusUnauthorized,
				http.StatusText(http.StatusUnauthorized),
			}

			ctx := req.Context()

			if jwtErr, ok := ctx.Value("jwt.err").(error); ok {
				if jwtErr != nil {
					c.render.JSON(rw, http.StatusUnauthorized, errResp)
					return
				}
			}

			jwtToken, ok := ctx.Value("jwt").(*jwt.Token)
			if !ok || jwtToken == nil || !jwtToken.Valid {
				c.render.JSON(rw, http.StatusUnauthorized, errResp)
				return
			}
		}

		next.ServeHTTP(rw, req)
	})
}
<commit_msg>Skip jwt validation if UnauthenticatedRoutes == *<commit_after>package minion

import (
	"net/http"

	jwt "github.com/dgrijalva/jwt-go"
)

// CreateJWTToken creates a jwt token with the given secret
func CreateJWTToken(claims map[string]interface{}) (string, error) {
	_, tokenString, err := tokenAuth.Encode(claims)

	return tokenString, err
}

// Authenticator ...
func (c *Context) Authenticator(next http.Handler) http.Handler {
	return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		if c.Engine.options.UnauthenticatedRoutes[0] != "*" {
			unauthenticated := false

			for _, path := range c.Engine.options.UnauthenticatedRoutes {
				if req.URL.Path == path {
					unauthenticated = true
				}
			}

			if !unauthenticated {
				errResp := struct {
					Code int    `json:"status"`
					Msg  string `json:"message"`
				}{
					http.StatusUnauthorized,
					http.StatusText(http.StatusUnauthorized),
				}

				ctx := req.Context()

				if jwtErr, ok := ctx.Value("jwt.err").(error); ok {
					if jwtErr != nil {
						c.render.JSON(rw, http.StatusUnauthorized, errResp)
						return
					}
				}

				jwtToken, ok := ctx.Value("jwt").(*jwt.Token)
				if !ok || jwtToken == nil || !jwtToken.Valid {
					c.render.JSON(rw, http.StatusUnauthorized, errResp)
					return
				}
			}

		}

		next.ServeHTTP(rw, req)
	})
}

{'fraction_non_alphanumeric': 0.13756819953234606, 'fraction_numerical': 0.0003897116134060795, 'mean_word_length': 3.1807817589576546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4947026', 'n_tokens_mistral': 1068, 'n_tokens_neox': 877, 'n_words': 185}