Skip to content

Commit

Permalink
make scopes configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
strifel committed Feb 18, 2024
1 parent f1d3733 commit 265c8f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
21 changes: 21 additions & 0 deletions flag_parsing/array_flag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package flag_parsing

type ScopeFlags []string

func (i *ScopeFlags) String() string {
// Return openid as default value
if len(*i) == 0 {
return "openid"
}
// Start with nothing
result := ""
for _, content := range *i {
result += content + "+"
}
return result[:len(result)-1]
}

func (i *ScopeFlags) Set(value string) error {
*i = append(*i, value)
return nil
}
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import (
"fmt"
"os/exec"

"github.com/strifel/openid-connect-debugger/flag_parsing"
getcode "github.com/strifel/openid-connect-debugger/get_code"
gettoken "github.com/strifel/openid-connect-debugger/get_token"
"github.com/strifel/openid-connect-debugger/start_connection"
startconnection "github.com/strifel/openid-connect-debugger/start_connection"
userdata "github.com/strifel/openid-connect-debugger/user_data"
)

func main() {
endpointUrl := flag.String("endpoint", "", "URL to instance")
clientId := flag.String("clientid", "", "Client ID")
secret := flag.String("secret", "", "Client Secret")
var scopes flag_parsing.ScopeFlags
flag.Var(&scopes, "scope", "Specify scopes (e.g. -scope profile -scope openid)")
verbosity := flag.Int("verbosity", 0, "Verbosity level (0 to 3). 2 is verbose, 3 shows the access token")
macosOpen := flag.Bool("macosopen", false, "Open the browser on MacOS")

Expand Down Expand Up @@ -54,7 +57,7 @@ func main() {

fmt.Println("Starting authorization phase")
fmt.Println("Please add http://localhost:8070/callback as valid redirect URI to your client")
authUrl := information.AuthorizationEndpoint + "?client_id=" + *clientId + "&response_type=code&scope=openid&redirect_uri=http://localhost:8070/callback"
authUrl := information.AuthorizationEndpoint + "?client_id=" + *clientId + "&response_type=code&scope=" + scopes.String() + "&redirect_uri=http://localhost:8070/callback"
fmt.Println("Then visit ", authUrl)

if *macosOpen {
Expand Down

0 comments on commit 265c8f9

Please sign in to comment.