mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-25 08:20:12 +00:00
create Idp
This commit is contained in:
@@ -1,57 +1,34 @@
|
||||
package oidc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"context"
|
||||
|
||||
"github.com/kkb0318/irsa-manager/internal/client"
|
||||
"github.com/kkb0318/irsa-manager/internal/selfhosted"
|
||||
)
|
||||
|
||||
type IdProvider struct {
|
||||
jwk *selfhosted.JWK
|
||||
issuerHostPath string
|
||||
jwksFileName string
|
||||
type AwsIdP struct {
|
||||
iamClient *client.AwsIamClient
|
||||
discovery selfhosted.OIDCIdPDiscovery
|
||||
}
|
||||
|
||||
type OIDCDiscoveryConfiguration struct {
|
||||
Issuer string `json:"issuer"`
|
||||
JWKSURI string `json:"jwks_uri"`
|
||||
AuthorizationEndpoint string `json:"authorization_endpoint"`
|
||||
ResponseTypesSupported []string `json:"response_types_supported"`
|
||||
SubjectTypesSupported []string `json:"subject_types_supported"`
|
||||
IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported"`
|
||||
ClaimsSupported []string `json:"claims_supported"`
|
||||
func NewAwsIdP(awsConfig *client.AwsConfig, discovery selfhosted.OIDCIdPDiscovery) (*AwsIdP, error) {
|
||||
iamClient := awsConfig.IamCient()
|
||||
return &AwsIdP{iamClient, discovery}, nil
|
||||
}
|
||||
|
||||
func (p *IdProvider) Discovery() ([]byte, error) {
|
||||
oidcConfig := OIDCDiscoveryConfiguration{
|
||||
Issuer: fmt.Sprintf("https://%s/", p.issuerHostPath),
|
||||
JWKSURI: fmt.Sprintf("https://%s/%s", p.issuerHostPath, p.jwksFileName),
|
||||
AuthorizationEndpoint: "urn:kubernetes:programmatic_authorization",
|
||||
ResponseTypesSupported: []string{"id_token"},
|
||||
SubjectTypesSupported: []string{"public"},
|
||||
IDTokenSigningAlgValuesSupported: []string{"RS256"},
|
||||
ClaimsSupported: []string{"sub", "iss"},
|
||||
}
|
||||
jsonData, err := json.MarshalIndent(oidcConfig, "", " ")
|
||||
func (a *AwsIdP) Create(ctx context.Context) (string, error) {
|
||||
arn, err := a.iamClient.CreateOIDCProvider(ctx, a.discovery.Endpoint())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
return jsonData, nil
|
||||
return arn, nil
|
||||
}
|
||||
|
||||
func (p *IdProvider) JWK() ([]byte, error) {
|
||||
jsonData, err := json.MarshalIndent(p.jwk.GetKeys(), "", " ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonData, nil
|
||||
func (a *AwsIdP) Update(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *IdProvider) Endpoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func NewIdProvider(jwk *selfhosted.JWK, issuerHostPath, jwksFileName string) *IdProvider {
|
||||
return &IdProvider{jwk, issuerHostPath, jwksFileName}
|
||||
func (a *AwsIdP) IsUpdate() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user