too much effort into the garbage
This commit is contained in:
@@ -2,13 +2,14 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.inhome.blapointe.com/local/oauth2"
|
||||
"gitea.inhome.blapointe.com/local/router"
|
||||
"gitea.inhome.blapointe.com/local/storage"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"gitea.inhome.blapointe.com/local/oauth2"
|
||||
"gitea.inhome.blapointe.com/local/router"
|
||||
"gitea.inhome.blapointe.com/local/storage"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -55,9 +56,9 @@ func (s *Server) authorize(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) genAuth(scope, user string) {
|
||||
access := uuid.New().String()
|
||||
token := uuid.New().String()
|
||||
s.store.Set(user, []byte(access), ACCESS)
|
||||
s.store.Set(scope+"."+access, []byte(token), TOKEN)
|
||||
s.store.Set(user, []byte(user), ACCESS)
|
||||
s.store.Set(access, []byte(user), ACCESS)
|
||||
}
|
||||
|
||||
func (s *Server) getAccess(scope, user string) (string, bool) {
|
||||
@@ -69,7 +70,10 @@ func (s *Server) getAccess(scope, user string) (string, bool) {
|
||||
return string(access), err == nil
|
||||
}
|
||||
|
||||
func (s *Server) getToken(scope, access string) (string, bool) {
|
||||
token, err := s.store.Get(scope+"."+access, TOKEN)
|
||||
return string(token), err == nil
|
||||
func (s *Server) verifyAccess(access string) error {
|
||||
_, err := s.store.Get(access, ACCESS)
|
||||
if err != nil {
|
||||
return fmt.Errorf("access not found: %s", access)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user