Minor changes

This commit is contained in:
David Allen 2024-02-24 09:09:05 -07:00
parent d1f9f9e46c
commit 3434368210
No known key found for this signature in database
GPG key ID: 1D2A29322FBB6FCB
3 changed files with 8 additions and 2 deletions

1
go.mod
View file

@ -3,6 +3,7 @@ module davidallendj/opaal
go 1.22.0 go 1.22.0
require ( require (
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/lestrrat-go/jwx v1.2.28 github.com/lestrrat-go/jwx v1.2.28
github.com/spf13/cobra v1.8.0 github.com/spf13/cobra v1.8.0
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0

2
go.sum
View file

@ -7,6 +7,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etly
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A= github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A=

View file

@ -169,7 +169,7 @@ func Login(config *Config) error {
fmt.Printf("failed to fetch JWK: %v\n", err) fmt.Printf("failed to fetch JWK: %v\n", err)
} else { } else {
fmt.Printf("Attempting to add issuer to authorization server...\n") fmt.Printf("Attempting to add issuer to authorization server...\n")
err = AddTrustedIssuer(config.ActionUrls.TrustedIssuers, *idp, subject, time.Duration(1000), config.Scope) err = AddTrustedIssuer(config.ActionUrls.TrustedIssuers, idp, subject, time.Duration(1000), config.Scope)
if err != nil { if err != nil {
return fmt.Errorf("failed to add trusted issuer: %v", err) return fmt.Errorf("failed to add trusted issuer: %v", err)
} }
@ -256,8 +256,11 @@ func FetchAccessToken(remoteUrl string, clientId string, jwt string, scopes []st
return token, nil return token, nil
} }
func AddTrustedIssuer(remoteUrl string, idp oidc.IdentityProvider, subject string, duration time.Duration, scope []string) error { func AddTrustedIssuer(remoteUrl string, idp *oidc.IdentityProvider, subject string, duration time.Duration, scope []string) error {
// hydra endpoint: /admin/trust/grants/jwt-bearer/issuers // hydra endpoint: /admin/trust/grants/jwt-bearer/issuers
if idp == nil {
return fmt.Errorf("identity provided is nil")
}
jwkstr, err := json.Marshal(idp.Key) jwkstr, err := json.Marshal(idp.Key)
if err != nil { if err != nil {
return fmt.Errorf("failed to marshal JWK: %v", err) return fmt.Errorf("failed to marshal JWK: %v", err)