Skip to content

Commit

Permalink
Add offline url validation for offline auth type
Browse files Browse the repository at this point in the history
Signed-off-by: Mehdy Khoshnoody <[email protected]>
  • Loading branch information
mehdy committed Aug 27, 2020
1 parent b109a2b commit f0bd8c7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"fmt"
"io/ioutil"
"net/url"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -82,6 +83,10 @@ func (l *Local) Validate() []error {
errors = append(errors, err)
}

if err := l.validateAuthOfflineURL(); err != nil {
errors = append(errors, err)
}

return errors
}

Expand All @@ -95,6 +100,14 @@ func (l *Local) validateIssueTracker() error {
l.IssueTracker, validIssueTrackers)
}

func (l *Local) validateAuthOfflineURL() error {
if _, err := url.ParseRequestURI(l.Auth.OfflineURL); l.Auth.Type == AuthTypeOffline && err != nil {
return fmt.Errorf("invalid offline URL: %q", l.Auth.OfflineURL)
}

return nil
}

func exists(filepath string) bool {
info, err := os.Stat(filepath)
if os.IsNotExist(err) {
Expand Down

0 comments on commit f0bd8c7

Please sign in to comment.