<commit_before>package main

import (
	"./models"
	"./storage"
	"database/sql"
	"errors"
	"fmt"
	"github.com/RangelReale/osin"
	"github.com/coopernurse/gorp"
	_ "github.com/go-sql-driver/mysql"
	"net/http"
	"os"
)

const (
	DB_TYPE       = "mysql"
	DB_ENCODING   = "UTF8"
	DB_ENGINE     = "InnoDB"
	DB_KEY        = "Id"
	DB_USER_TABLE = "user"
	REDIS_HOST    = "localhost:6379"
	REDIS_PREFIX  = "auth"
)

var server *osin.Server
var dbmap *gorp.DbMap

func tokenHandler(w http.ResponseWriter, r *http.Request) {
	resp := server.NewResponse()
	defer resp.Close()
	if ar := server.HandleAccessRequest(resp, r); ar != nil {
		switch ar.Type {
		case osin.PASSWORD:
			if ar.Username == "test" && ar.Password == "<PASSWORD>" {
				ar.Authorized = true
			}
		}
		server.FinishAccessRequest(resp, r, ar)
	}
	if resp.IsError && resp.InternalError != nil {
		fmt.Printf("ERROR: %s\n", resp.InternalError)<commit_msg>[PLATFORM-555] Validating credentials of our mysql users<commit_after>package main

import (
	"./models"
	"./storage"
	"database/sql"
	"errors"
	"fmt"
	"github.com/RangelReale/osin"
	"github.com/coopernurse/gorp"
	_ "github.com/go-sql-driver/mysql"
	"net/http"
	"os"
)

const (
	DB_TYPE       = "mysql"
	DB_ENCODING   = "UTF8"
	DB_ENGINE     = "InnoDB"
	DB_KEY        = "Id"
	DB_USER_TABLE = "user"
	REDIS_HOST    = "localhost:6379"
	REDIS_PREFIX  = "auth"
)

var server *osin.Server
var dbmap *gorp.DbMap

func tokenHandler(w http.ResponseWriter, r *http.Request) {
	resp := server.NewResponse()
	defer resp.Close()
	if ar := server.HandleAccessRequest(resp, r); ar != nil {
		switch ar.Type {
		case osin.PASSWORD:
			user := models.User{Name: ar.Username}
			user.FindByName(dbmap)
			if user.ValidPassword(ar.Password) {
				ar.Authorized = true
			}
		}
		server.FinishAccessRequest(resp, r, ar)
	}
	if resp.IsError && resp.InternalError != nil {
		fmt.Printf("ERROR: %s\n", resp.InternalError)
{'fraction_non_alphanumeric': 0.14937106918238993, 'fraction_numerical': 0.006813417190775681, 'mean_word_length': 3.545238095238095, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '838233', 'n_tokens_mistral': 801, 'n_tokens_neox': 753, 'n_words': 146}