Commit 593b0860 authored by Alexis POYEN's avatar Alexis POYEN
Browse files

Feat : add AuthType field to technical user

parent 9c16a0b2
......@@ -9,8 +9,8 @@ import (
"strings"
"time"
"forge.grandlyon.com/apoyen/sdk-go/pkg/auth"
"github.com/jinzhu/gorm"
"github.com/nicolaspernoud/vestibule/pkg/auth"
// Needed for sqlite
......
......@@ -11,11 +11,11 @@ import (
"regexp"
"testing"
"forge.grandlyon.com/apoyen/sdk-go/pkg/tester"
"github.com/nicolaspernoud/vestibule/pkg/auth"
"github.com/nicolaspernoud/vestibule/pkg/tester"
"github.com/nicolaspernoud/vestibule/pkg/tokens"
"github.com/nicolaspernoud/vestibule/internal/mocks"
"forge.grandlyon.com/apoyen/sdk-go/internal/mocks"
)
var (
......@@ -115,8 +115,6 @@ func UnLoggedTests(t *testing.T) {
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("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 (
type User struct {
ID string `json:"id,omitempty"`
Login string `json:"login"`
AuthType string `json:authType`
DisplayName string `json:"displayName,omitempty"`
Roles []string `json:"memberOf"`
IsAdmin bool `json:"isAdmin,omitempty"`
......
......@@ -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))
return
}
user.AuthType = "local"
// Store the user in cookie
// Store only the relevant info
// Generate
......
......@@ -112,6 +112,7 @@ func (m Manager) HandleOAuth2Callback() http.Handler {
for key, role := range user.Roles {
user.Roles[key] = strings.TrimPrefix(strings.Split(role, ",")[0], "CN=")
}
user.AuthType = "OAuth2"
// Store the user in cookie
// Generate
xsrfToken, err := common.GenerateRandomString(16)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment