Skip to content

Commit

Permalink
Add dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Patel committed Jul 30, 2023
1 parent bcb4ba6 commit 37d6327
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:

.PHONY: dev
dev: build
srepanel/srepanel -config test_config.json
srepanel/srepanel -dev -config test_config.json

.PHONY: jaas
jaas:
Expand Down
15 changes: 15 additions & 0 deletions srepanel/web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ func (s *Server) handleLogin(wr http.ResponseWriter, req *http.Request) {
panic(err)
}
case http.MethodPost:
if s.Config.Dev {
ident := &common.Identity{
ID: 1,
Username: "testuser",
}
http.SetCookie(wr, &http.Cookie{
Name: "token",
Value: s.Issuer.Issue(ident),
Path: "/",
HttpOnly: true,
Secure: true,
})
http.Redirect(wr, req, "/", http.StatusTemporaryRedirect)
return
}
authURL := s.Auth.AuthURL()
http.Redirect(wr, req, authURL, http.StatusTemporaryRedirect)
default:
Expand Down

0 comments on commit 37d6327

Please sign in to comment.