forked from efixler/scrape
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add token entry/storage functionality to test console #7
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ffecac3
Working Alpine, with iframe
efixler 2a13044
- Remove iframe
efixler 25fc6a7
Update CSS box model
efixler feb5392
Re-hide the token field to cut this PR before material auth changes
efixler 7362a59
Review feedback
efixler 6433379
Add textarea for token entry
efixler e2212e1
Change checkbox to button(s)
efixler 920211a
Make url entry row properly responsive
efixler f8d6ff0
- Tweak CSS layout
efixler 5bd3d68
- Save and clear token
efixler 0ae3e74
Alert when token saved
efixler 2a5cd93
Remove unused CSS classes
efixler 5263f71
Add a little more padding-bottom to the Enter a URL label
efixler 3c6846f
Change Enter Token toggle from button to +/-
efixler 94d1eaa
Merge remote-tracking branch 'origin/main' into token-control
efixler 17e2663
Fix js error when auth is disabled
efixler 71b969b
Formatting
efixler 94bd09d
Tabs to spaces
efixler 2c52338
Fix Makefile when go not present
efixler f52bf20
grr remove extra line
efixler 9b77e61
Add TODO
efixler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,9 +107,10 @@ var home embed.FS | |
|
||
func (h scrapeServer) mustHomeTemplate() *template.Template { | ||
tmpl := template.New("home") | ||
var keyF = func() string { return "" } | ||
if len(h.SigningKey) > 0 { | ||
keyF = func() string { | ||
var authTokenF = func() string { return "" } | ||
var authEnabledF = func() bool { return len(h.SigningKey) > 0 } | ||
if authEnabledF() { | ||
authTokenF = func() string { | ||
c, err := auth.NewClaims( | ||
auth.WithSubject("home"), | ||
auth.ExpiresIn(60*time.Minute), | ||
|
@@ -126,7 +127,11 @@ func (h scrapeServer) mustHomeTemplate() *template.Template { | |
return s | ||
} | ||
} | ||
tmpl = tmpl.Funcs(template.FuncMap{"AuthToken": keyF}) | ||
funcMap := template.FuncMap{ | ||
"AuthToken": authTokenF, | ||
"AuthEnabled": authEnabledF, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds the hook so we can skip the token entry widget when auth is not enabled |
||
} | ||
tmpl = tmpl.Funcs(funcMap) | ||
homeSource, _ := home.ReadFile("templates/index.html") | ||
tmpl = template.Must(tmpl.Parse(string(homeSource))) | ||
return tmpl | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just renamed this to make it a little more descriptive.