Przeglądaj źródła

Added working oauth

Toby Chui 6 miesięcy temu
rodzic
commit
91a9d76e4c
1 zmienionych plików z 8 dodań i 8 usunięć
  1. 8 8
      mod/auth/sso/oauth2.go

+ 8 - 8
mod/auth/sso/oauth2.go

@@ -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
 		}