|
@@ -41,12 +41,12 @@ func NewOAuth2Server(config *SSOConfig, parent *SSOHandler) (*OAuth2Server, erro
|
|
|
// generate jwt access token
|
|
|
manager.MapAccessGenerate(generates.NewAccessGenerate())
|
|
|
|
|
|
- //Load user information from SSO_USERS
|
|
|
+ //Load the information of registered app within the OAuth2 server
|
|
|
clientStore := store.NewClientStore()
|
|
|
- clientStore.Set("alanyeung", &models.Client{
|
|
|
- ID: "alanyeung",
|
|
|
- Secret: "password",
|
|
|
- Domain: "localhost:8000",
|
|
|
+ clientStore.Set("myapp", &models.Client{
|
|
|
+ ID: "myapp",
|
|
|
+ Secret: "verysecurepassword",
|
|
|
+ Domain: "localhost:9094",
|
|
|
})
|
|
|
manager.MapClientStorage(clientStore)
|
|
|
|
|
@@ -176,20 +176,20 @@ func (oas *OAuth2Server) loginHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
//Load username and password from form post
|
|
|
username, err := utils.PostPara(r, "username")
|
|
|
if err != nil {
|
|
|
- w.Write([]byte("Invalid username or password"))
|
|
|
+ w.Write([]byte("invalid username or password"))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
password, err := utils.PostPara(r, "password")
|
|
|
if err != nil {
|
|
|
- w.Write([]byte("Invalid username or password"))
|
|
|
+ w.Write([]byte("invalid username or password"))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//Validate the user
|
|
|
if !oas.parent.ValidateUsernameAndPassword(username, password) {
|
|
|
//Wrong password
|
|
|
- w.Write([]byte("Invalid username or password"))
|
|
|
+ w.Write([]byte("invalid username or password"))
|
|
|
return
|
|
|
}
|
|
|
|