forked from vikunja/vikunja
Update authentication flow as per request
This commit is contained in:
parent
d9e4ace5ba
commit
80c9d9c2d7
@ -149,8 +149,6 @@ const (
|
||||
MigrationMicrosoftTodoClientSecret Key = `migration.microsofttodo.clientsecret`
|
||||
MigrationMicrosoftTodoRedirectURL Key = `migration.microsofttodo.redirecturl`
|
||||
MigrationKanboardEnable Key = `migration.kanboard.enable`
|
||||
MigrationKanboardApiToken Key = `migration.kanboard.token`
|
||||
MigrationKanboardApiEndpoint Key = `migration.kanboard.endpoint`
|
||||
MigrationKanboardApiInsecure Key = `migration.kanboard.insecure`
|
||||
|
||||
CorsEnable Key = `cors.enable`
|
||||
|
@ -32,7 +32,9 @@ import (
|
||||
|
||||
// Migration represents the kanboard migration struct
|
||||
type Migration struct {
|
||||
Token string `json:"code"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type kanboardBoard struct {
|
||||
@ -80,7 +82,7 @@ func (m *Migration) Name() string {
|
||||
// @Failure 500 {object} models.Message "Internal server error"
|
||||
// @Router /migration/kanboard/auth [get]
|
||||
func (m *Migration) AuthURL() string {
|
||||
return config.MigrationKanboardApiEndpoint.GetString()
|
||||
return ""
|
||||
}
|
||||
|
||||
func basicAuth(username, password string) string {
|
||||
@ -88,7 +90,7 @@ func basicAuth(username, password string) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(auth))
|
||||
}
|
||||
|
||||
func getKanboardData(endpoint string, token string, allowInsecure bool) (kanboardData []kanboardBoard, err error) {
|
||||
func getKanboardData(endpoint string, username string, password string, allowInsecure bool) (kanboardData []kanboardBoard, err error) {
|
||||
|
||||
var tr *http.Transport
|
||||
|
||||
@ -103,7 +105,7 @@ func getKanboardData(endpoint string, token string, allowInsecure bool) (kanboar
|
||||
client := &http.Client{Transport: tr}
|
||||
|
||||
auth := make(map[string]string)
|
||||
auth["Authorization"] = "Basic " + basicAuth("jsonrpc", token)
|
||||
auth["Authorization"] = "Basic " + basicAuth(username, password)
|
||||
|
||||
opts := jsonrpc.RPCClientOpts{
|
||||
HTTPClient: client,
|
||||
@ -119,7 +121,7 @@ func getKanboardData(endpoint string, token string, allowInsecure bool) (kanboar
|
||||
|
||||
// Converts all previously obtained data from kanboard into the vikunja format.
|
||||
// `kanboardData` should contain all boards with their projects and cards respectively.
|
||||
func convertKanboardDataToVikunja(kanboardData []kanboardBoard, token string) (fullVikunjaHierachie []*models.ProjectWithTasksAndBuckets, err error) {
|
||||
func convertKanboardDataToVikunja(kanboardData []kanboardBoard) (fullVikunjaHierachie []*models.ProjectWithTasksAndBuckets, err error) {
|
||||
|
||||
log.Debugf("[Kanboard Migration] ")
|
||||
|
||||
@ -153,8 +155,9 @@ func (m *Migration) Migrate(u *user.User) (err error) {
|
||||
log.Debugf("[Kanboard Migration] Getting all kanboard data for user %d", u.ID)
|
||||
|
||||
kanboardData, err := getKanboardData(
|
||||
config.MigrationKanboardApiEndpoint.GetString(),
|
||||
config.MigrationKanboardApiToken.GetString(),
|
||||
m.Endpoint,
|
||||
m.Username,
|
||||
m.Password,
|
||||
config.MigrationKanboardApiInsecure.GetBool(),
|
||||
)
|
||||
if err != nil {
|
||||
@ -164,7 +167,7 @@ func (m *Migration) Migrate(u *user.User) (err error) {
|
||||
log.Debugf("[Kanboard Migration] Got all kanboard data for user %d", u.ID)
|
||||
log.Debugf("[Kanboard Migration] Start converting kanboard data for user %d", u.ID)
|
||||
|
||||
fullVikunjaHierachie, err := convertKanboardDataToVikunja(kanboardData, m.Token)
|
||||
fullVikunjaHierachie, err := convertKanboardDataToVikunja(kanboardData)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user