Skip to content

Commit

Permalink
add raw id_token in output
Browse files Browse the repository at this point in the history
closes #101
  • Loading branch information
BeryJu committed May 8, 2024
1 parent 3c962c5 commit 262af9b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ brews:
email: [email protected]
homepage: 'https://github.com/beryju/{{ .ProjectName }}'
description: 'Small, OIDC Client, to debug and test OIDC providers'
folder: Formula
directory: Formula
4 changes: 3 additions & 1 deletion cmd/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"net/http"
"os"

"github.com/cli/oauth"
"github.com/spf13/cobra"
Expand All @@ -25,6 +26,7 @@ var deviceCmd = &cobra.Command{
flow := &oauth.Flow{
Host: &oauth.Host{
DeviceCodeURL: deviceUrl,
TokenURL: codeUrl,
},
ClientID: clientId,
Scopes: scopes,
Expand All @@ -41,7 +43,7 @@ var deviceCmd = &cobra.Command{
}

func init() {
deviceCmd.PersistentFlags().StringVarP(&clientId, "client-id", "c", "", "Client ID")
deviceCmd.PersistentFlags().StringVarP(&clientId, "client-id", "c", os.Getenv("OIDC_CLIENT_ID"), "Client ID")
deviceCmd.PersistentFlags().StringVarP(&deviceUrl, "device-url", "d", "", "Device URL")
deviceCmd.PersistentFlags().StringVarP(&codeUrl, "code-url", "u", "", "Code URL")
deviceCmd.PersistentFlags().StringSliceVarP(&scopes, "scopes", "s", []string{}, "Scopes")
Expand Down
3 changes: 2 additions & 1 deletion pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (c *OIDCClient) oauthCallback(w http.ResponseWriter, r *http.Request) {
resp := CallbackResponse{
OAuth2Token: oauth2Token,
IDTokenClaims: new(json.RawMessage),
RawIDToken: rawIDToken,
}

if err := idToken.Claims(&resp.IDTokenClaims); err != nil {
Expand Down Expand Up @@ -230,7 +231,7 @@ func (c *OIDCClient) oauthInit(w http.ResponseWriter, r *http.Request) {
return
}
opts := []oauth2.AuthCodeOption{}
if slices.Contains(c.config.Scopes, "offline_access") {
if slices.Contains(c.config.Scopes, oidc.ScopeOfflineAccess) {
opts = append(opts, oauth2.ApprovalForce)
}
if c.doRefreshChecks {
Expand Down
1 change: 1 addition & 0 deletions pkg/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func Env(key string, fallback string) string {
type CallbackResponse struct {
OAuth2Token *oauth2.Token
IDTokenClaims *json.RawMessage // ID Token payload is just JSON.
RawIDToken string
UserInfo interface{}
Introspection interface{}
Refresh interface{}
Expand Down
1 change: 0 additions & 1 deletion pkg/implicit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pkg

import (
"embed"
_ "embed"
"html/template"
"net/http"
"strings"
Expand Down

0 comments on commit 262af9b

Please sign in to comment.