Skip to content
Snippets Groups Projects
Commit 593b0860 authored by Alexis Poyen's avatar Alexis Poyen
Browse files

Feat : add AuthType field to technical user

parent 9c16a0b2
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,8 @@ import ( ...@@ -9,8 +9,8 @@ import (
"strings" "strings"
"time" "time"
"forge.grandlyon.com/apoyen/sdk-go/pkg/auth"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"github.com/nicolaspernoud/vestibule/pkg/auth"
// Needed for sqlite // Needed for sqlite
......
...@@ -11,11 +11,11 @@ import ( ...@@ -11,11 +11,11 @@ import (
"regexp" "regexp"
"testing" "testing"
"forge.grandlyon.com/apoyen/sdk-go/pkg/tester"
"github.com/nicolaspernoud/vestibule/pkg/auth" "github.com/nicolaspernoud/vestibule/pkg/auth"
"github.com/nicolaspernoud/vestibule/pkg/tester"
"github.com/nicolaspernoud/vestibule/pkg/tokens" "github.com/nicolaspernoud/vestibule/pkg/tokens"
"github.com/nicolaspernoud/vestibule/internal/mocks" "forge.grandlyon.com/apoyen/sdk-go/internal/mocks"
) )
var ( var (
...@@ -115,8 +115,6 @@ func UnLoggedTests(t *testing.T) { ...@@ -115,8 +115,6 @@ func UnLoggedTests(t *testing.T) {
do("POST", "/Login", noH, `{"login": "unknownuser","password": "password"}`, http.StatusForbidden, `user not found`) do("POST", "/Login", noH, `{"login": "unknownuser","password": "password"}`, http.StatusForbidden, `user not found`)
// Do a in memory login with a known user but bad password // Do a in memory login with a known user but bad password
do("POST", "/Login", noH, `{"login": "admin","password": "badpassword"}`, http.StatusForbidden, `user not found`) do("POST", "/Login", noH, `{"login": "admin","password": "badpassword"}`, http.StatusForbidden, `user not found`)
// Try to get a share token (must fail)
do("POST", "/api/common/Share", noH, `{"sharedfor":"guest","url":"userdav.vestibule.io/mydata/test.txt","lifespan":1,"readonly":true}`, 401, "error extracting token")
} }
/** /**
......
File mode changed from 100644 to 100755
...@@ -26,6 +26,7 @@ const ( ...@@ -26,6 +26,7 @@ const (
type User struct { type User struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Login string `json:"login"` Login string `json:"login"`
AuthType string `json:authType`
DisplayName string `json:"displayName,omitempty"` DisplayName string `json:"displayName,omitempty"`
Roles []string `json:"memberOf"` Roles []string `json:"memberOf"`
IsAdmin bool `json:"isAdmin,omitempty"` IsAdmin bool `json:"isAdmin,omitempty"`
......
...@@ -40,6 +40,7 @@ func (m Manager) HandleInMemoryLogin(w http.ResponseWriter, r *http.Request) { ...@@ -40,6 +40,7 @@ func (m Manager) HandleInMemoryLogin(w http.ResponseWriter, r *http.Request) {
log.Logger.Printf("| %v | Login failure | %v | %v", sentUser.Login, r.RemoteAddr, log.GetCityAndCountryFromRequest(r)) log.Logger.Printf("| %v | Login failure | %v | %v", sentUser.Login, r.RemoteAddr, log.GetCityAndCountryFromRequest(r))
return return
} }
user.AuthType = "local"
// Store the user in cookie // Store the user in cookie
// Store only the relevant info // Store only the relevant info
// Generate // Generate
......
...@@ -112,6 +112,7 @@ func (m Manager) HandleOAuth2Callback() http.Handler { ...@@ -112,6 +112,7 @@ func (m Manager) HandleOAuth2Callback() http.Handler {
for key, role := range user.Roles { for key, role := range user.Roles {
user.Roles[key] = strings.TrimPrefix(strings.Split(role, ",")[0], "CN=") user.Roles[key] = strings.TrimPrefix(strings.Split(role, ",")[0], "CN=")
} }
user.AuthType = "OAuth2"
// Store the user in cookie // Store the user in cookie
// Generate // Generate
xsrfToken, err := common.GenerateRandomString(16) xsrfToken, err := common.GenerateRandomString(16)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment