refactor: only accept claims following the OIDC spec

This commit is contained in:
Stavros
2025-04-25 15:28:24 +03:00
parent 13032e564d
commit 5e4e2ddbd9
7 changed files with 32 additions and 19 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"io"
"net/http"
"tinyauth/internal/constants"
"github.com/rs/zerolog/log"
)
@@ -13,9 +14,9 @@ func GoogleScopes() []string {
return []string{"https://www.googleapis.com/auth/userinfo.email"}
}
func GetGoogleUser(client *http.Client) (map[string]interface{}, error) {
func GetGoogleUser(client *http.Client) (constants.Claims, error) {
// Create user struct
user := make(map[string]interface{})
var user constants.Claims
// Get the user info from google using the oauth http client
res, err := client.Get("https://www.googleapis.com/userinfo/v2/me")