2019-02-21 08:41:09 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2019-02-21 13:23:29 +01:00
|
|
|
"net/http"
|
2019-02-21 08:41:09 +01:00
|
|
|
"net/url"
|
|
|
|
)
|
|
|
|
|
|
|
|
func handleOauth2() {
|
|
|
|
http.HandleFunc("/-/user", func(w http.ResponseWriter, r *http.Request) {
|
2019-02-21 13:23:29 +01:00
|
|
|
fullNameMap, _ := url.ParseQuery(r.Header.Get("X-Auth-Request-Fullname"))
|
2019-02-21 08:41:09 +01:00
|
|
|
var fullName string
|
|
|
|
for k := range fullNameMap {
|
|
|
|
fullName = k
|
|
|
|
break
|
|
|
|
}
|
|
|
|
user := &UserInfo{
|
|
|
|
Email: r.Header.Get("X-Auth-Request-Email"),
|
|
|
|
Name: fullName,
|
|
|
|
NickName: r.Header.Get("X-Auth-Request-User"),
|
|
|
|
}
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
data, _ := json.Marshal(user)
|
|
|
|
w.Write(data)
|
|
|
|
})
|
|
|
|
}
|