|
|
@ -197,7 +197,7 @@ func AuthHandler(ctx *Context, server *GQLThread) func(http.ResponseWriter, *htt
|
|
|
|
|
|
|
|
|
|
|
|
key_id := KeyID(remote_id)
|
|
|
|
key_id := KeyID(remote_id)
|
|
|
|
|
|
|
|
|
|
|
|
_, exists := server.Users[key_id]
|
|
|
|
_, exists := server.UserMap[key_id]
|
|
|
|
if exists {
|
|
|
|
if exists {
|
|
|
|
ctx.Log.Logf("gql", "REFRESHING AUTH FOR %s", key_id)
|
|
|
|
ctx.Log.Logf("gql", "REFRESHING AUTH FOR %s", key_id)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -215,7 +215,7 @@ func AuthHandler(ctx *Context, server *GQLThread) func(http.ResponseWriter, *htt
|
|
|
|
Resources: nil,
|
|
|
|
Resources: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}), func(context *StateContext) error {
|
|
|
|
}), func(context *StateContext) error {
|
|
|
|
server.Users[key_id] = &new_user
|
|
|
|
server.UserMap[key_id] = &new_user
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -378,7 +378,7 @@ func NewResolveContext(ctx *Context, server *GQLThread, r *http.Request) (*Resol
|
|
|
|
return nil, fmt.Errorf("GQL_REQUEST_ERR: failed to parse ID from auth username: %s", username)
|
|
|
|
return nil, fmt.Errorf("GQL_REQUEST_ERR: failed to parse ID from auth username: %s", username)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
user, exists := server.Users[auth_id]
|
|
|
|
user, exists := server.UserMap[auth_id]
|
|
|
|
if exists == false {
|
|
|
|
if exists == false {
|
|
|
|
return nil, fmt.Errorf("GQL_REQUEST_ERR: no existing authorization for client %s", auth_id)
|
|
|
|
return nil, fmt.Errorf("GQL_REQUEST_ERR: no existing authorization for client %s", auth_id)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -636,7 +636,7 @@ type GQLThread struct {
|
|
|
|
tls_key []byte
|
|
|
|
tls_key []byte
|
|
|
|
tls_cert []byte
|
|
|
|
tls_cert []byte
|
|
|
|
Listen string
|
|
|
|
Listen string
|
|
|
|
Users map[NodeID]*User
|
|
|
|
UserMap map[NodeID]*User
|
|
|
|
Key *ecdsa.PrivateKey
|
|
|
|
Key *ecdsa.PrivateKey
|
|
|
|
ECDH ecdh.Curve
|
|
|
|
ECDH ecdh.Curve
|
|
|
|
SubscribeLock sync.Mutex
|
|
|
|
SubscribeLock sync.Mutex
|
|
|
@ -681,6 +681,10 @@ func (thread * GQLThread) Serialize() ([]byte, error) {
|
|
|
|
return json.MarshalIndent(&thread_json, "", " ")
|
|
|
|
return json.MarshalIndent(&thread_json, "", " ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (thread * GQLThread) Users() map[NodeID]*User {
|
|
|
|
|
|
|
|
return thread.UserMap
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type GQLThreadJSON struct {
|
|
|
|
type GQLThreadJSON struct {
|
|
|
|
ThreadJSON
|
|
|
|
ThreadJSON
|
|
|
|
Listen string `json:"listen"`
|
|
|
|
Listen string `json:"listen"`
|
|
|
@ -715,9 +719,9 @@ func NewGQLThreadJSON(thread *GQLThread) GQLThreadJSON {
|
|
|
|
panic(err)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
users := make([]string, len(thread.Users))
|
|
|
|
users := make([]string, len(thread.UserMap))
|
|
|
|
i := 0
|
|
|
|
i := 0
|
|
|
|
for id, _ := range(thread.Users) {
|
|
|
|
for id, _ := range(thread.UserMap) {
|
|
|
|
users[i] = id.String()
|
|
|
|
users[i] = id.String()
|
|
|
|
i += 1
|
|
|
|
i += 1
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -747,7 +751,7 @@ var LoadGQLThread = LoadJSONNode(func(id NodeID, j GQLThreadJSON) (Node, error)
|
|
|
|
thread := NewGQLThread(id, j.Name, j.StateName, j.Listen, ecdh_curve, key, j.TLSCert, j.TLSKey)
|
|
|
|
thread := NewGQLThread(id, j.Name, j.StateName, j.Listen, ecdh_curve, key, j.TLSCert, j.TLSKey)
|
|
|
|
return &thread, nil
|
|
|
|
return &thread, nil
|
|
|
|
}, func(ctx *Context, thread *GQLThread, j GQLThreadJSON, nodes NodeMap) error {
|
|
|
|
}, func(ctx *Context, thread *GQLThread, j GQLThreadJSON, nodes NodeMap) error {
|
|
|
|
thread.Users = map[NodeID]*User{}
|
|
|
|
thread.UserMap = map[NodeID]*User{}
|
|
|
|
for _, id_str := range(j.Users) {
|
|
|
|
for _, id_str := range(j.Users) {
|
|
|
|
ctx.Log.Logf("db", "THREAD_LOAD_USER: %s", id_str)
|
|
|
|
ctx.Log.Logf("db", "THREAD_LOAD_USER: %s", id_str)
|
|
|
|
user_id, err := ParseID(id_str)
|
|
|
|
user_id, err := ParseID(id_str)
|
|
|
@ -758,7 +762,7 @@ var LoadGQLThread = LoadJSONNode(func(id NodeID, j GQLThreadJSON) (Node, error)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
thread.Users[user_id] = user.(*User)
|
|
|
|
thread.UserMap[user_id] = user.(*User)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return RestoreThread(ctx, thread, j.ThreadJSON, nodes)
|
|
|
|
return RestoreThread(ctx, thread, j.ThreadJSON, nodes)
|
|
|
@ -808,7 +812,7 @@ func NewGQLThread(id NodeID, name string, state_name string, listen string, ecdh
|
|
|
|
Thread: NewThread(id, name, state_name, []InfoType{"parent"}, gql_actions, gql_handlers),
|
|
|
|
Thread: NewThread(id, name, state_name, []InfoType{"parent"}, gql_actions, gql_handlers),
|
|
|
|
Listen: listen,
|
|
|
|
Listen: listen,
|
|
|
|
SubscribeListeners: []chan GraphSignal{},
|
|
|
|
SubscribeListeners: []chan GraphSignal{},
|
|
|
|
Users: map[NodeID]*User{},
|
|
|
|
UserMap: map[NodeID]*User{},
|
|
|
|
http_done: &sync.WaitGroup{},
|
|
|
|
http_done: &sync.WaitGroup{},
|
|
|
|
Key: key,
|
|
|
|
Key: key,
|
|
|
|
ECDH: ecdh_curve,
|
|
|
|
ECDH: ecdh_curve,
|
|
|
|