mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Fixed imports from project name change
This commit is contained in:
parent
02cbc2f2eb
commit
6c0f1303ac
3 changed files with 9 additions and 7 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"davidallendj/opal/internal/oauth"
|
"davidallendj/opaal/internal/oauth"
|
||||||
"davidallendj/opal/internal/oidc"
|
"davidallendj/opaal/internal/oidc"
|
||||||
"davidallendj/opal/internal/util"
|
"davidallendj/opaal/internal/util"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
|
||||||
|
|
@ -107,11 +107,11 @@ var loginCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch JWKS and add issuer to authentication server to submit ID token
|
// fetch JWKS and add issuer to authentication server to submit ID token
|
||||||
jwk, err := api.FetchJwk("")
|
err = idp.FetchJwk("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("failed to fetch JWK: %v\n", err)
|
fmt.Printf("failed to fetch JWK: %v\n", err)
|
||||||
} else {
|
} else {
|
||||||
api.AddTrustedIssuer(config.AuthEndpoints.TrustedIssuers, jwk.(string))
|
api.AddTrustedIssuer(config.AuthEndpoints.TrustedIssuers, idp.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// use ID token/user info to fetch access token from authentication server
|
// use ID token/user info to fetch access token from authentication server
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/lestrrat-go/jwx/jwk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WaitForAuthorizationCode(serverAddr string, loginUrl string) (string, error) {
|
func WaitForAuthorizationCode(serverAddr string, loginUrl string) (string, error) {
|
||||||
|
|
@ -78,7 +80,7 @@ func FetchAccessToken(remoteUrl string, clientId string, jwt string, scopes []st
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddTrustedIssuer(remoteUrl string, issuer string, subject string, duration time.Duration, jwk string, scope []string) error {
|
func AddTrustedIssuer(remoteUrl string, issuer string, subject string, duration time.Duration, jwk jwk.Key, scope []string) error {
|
||||||
// hydra endpoint: /admin/trust/grants/jwt-bearer/issuers
|
// hydra endpoint: /admin/trust/grants/jwt-bearer/issuers
|
||||||
data := []byte(fmt.Sprintf(`{
|
data := []byte(fmt.Sprintf(`{
|
||||||
"allow_any_subject": false,
|
"allow_any_subject": false,
|
||||||
|
|
@ -87,7 +89,7 @@ func AddTrustedIssuer(remoteUrl string, issuer string, subject string, duration
|
||||||
"expires_at": "%v"
|
"expires_at": "%v"
|
||||||
"jwk": %v,
|
"jwk": %v,
|
||||||
"scope": [ j%s ],
|
"scope": [ j%s ],
|
||||||
}`, issuer, subject, time.Now().Add(duration), jwk, strings.Join(scope, ",")))
|
}`, issuer, subject, time.Now().Add(duration), string(jwk), strings.Join(scope, ",")))
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", remoteUrl, bytes.NewBuffer(data))
|
req, err := http.NewRequest("POST", remoteUrl, bytes.NewBuffer(data))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue