refact: to use go-dbw CreateItems, DeleteItems (#4974)

* refact: to use go-dbw CreateItems, DeleteItems

Latest version of go-dbw updated the signature of
CreateItems(...) and DeleteItems(...) on a happy
note this latest version of go-dbw actually does
batch inserts and updates for this functions.

* all: regenerate protos with new protoc-gen-go version
This commit is contained in:
Jim authored and GitHub committed 2024-08-01 11:18:53 -04:00
1 parent b24f6dcee8
commit 28b465e4b8
167 files changed
+2254 -2248

No files matched your search

+39 -39
View File
@@ -141,14 +141,14 @@ func (am *AuthMethod) oplog(ctx context.Context, opType oplog.OpType) (oplog.Met
}
type convertedValues struct {
Urls []any
Certs []any
UserEntrySearchConf any
GroupEntrySearchConf any
ClientCertificate any
BindCredential any
AccountAttributeMaps []any
DerefAliases any
Urls []*Url
Certs []*Certificate
UserEntrySearchConf *UserEntrySearchConf
GroupEntrySearchConf *GroupEntrySearchConf
ClientCertificate *ClientCertificate
BindCredential *BindCredential
AccountAttributeMaps []*AccountAttributeMap
DerefAliases *DerefAliases
}
// convertValueObjects converts the embedded value objects. It will return an
@@ -199,15 +199,15 @@ func (am *AuthMethod) convertValueObjects(ctx context.Context) (*convertedValues
return converted, nil
}
// convertCertificates converts any embedded URLs from []string
// to []any where each slice element is a *Url. It will return an error if the
// AuthMethod's public id is not set.
func (am *AuthMethod) convertUrls(ctx context.Context) ([]any, error) {
// convertUrls converts any embedded URLs from []string to []*Url where each
// slice element is a *Url. It will return an error if the AuthMethod's public
// id is not set.
func (am *AuthMethod) convertUrls(ctx context.Context) ([]*Url, error) {
const op = "ldap.(AuthMethod).convertUrls"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newValObjs := make([]any, 0, len(am.Urls))
newValObjs := make([]*Url, 0, len(am.Urls))
for priority, u := range am.Urls {
parsed, err := url.Parse(u)
if err != nil {
@@ -223,14 +223,14 @@ func (am *AuthMethod) convertUrls(ctx context.Context) ([]any, error) {
}
// convertCertificates converts any embedded certificates from []string
// to []any where each slice element is a *Certificate. It will return an error
// if the AuthMethod's public id is not set.
func (am *AuthMethod) convertCertificates(ctx context.Context) ([]any, error) {
// to []*Certificate. It will return an error if the AuthMethod's public id is
// not set.
func (am *AuthMethod) convertCertificates(ctx context.Context) ([]*Certificate, error) {
const op = "ldap.(AuthMethod).convertCertificates"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newValObjs := make([]any, 0, len(am.Certificates))
newValObjs := make([]*Certificate, 0, len(am.Certificates))
for _, cert := range am.Certificates {
obj, err := NewCertificate(ctx, am.PublicId, cert)
if err != nil {
@@ -242,9 +242,9 @@ func (am *AuthMethod) convertCertificates(ctx context.Context) ([]any, error) {
}
// convertUserEntrySearchConf converts an embedded user entry search fields
// into an any type. It will return an error if the AuthMethod's public id is
// not set.
func (am *AuthMethod) convertUserEntrySearchConf(ctx context.Context) (any, error) {
// into an *UserEntrySearchConf type. It will return an error if the
// AuthMethod's public id is not set.
func (am *AuthMethod) convertUserEntrySearchConf(ctx context.Context) (*UserEntrySearchConf, error) {
const op = "ldap.(AuthMethod).convertUserEntrySearchConf"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
@@ -257,9 +257,9 @@ func (am *AuthMethod) convertUserEntrySearchConf(ctx context.Context) (any, erro
}
// convertGroupEntrySearchConf converts an embedded group entry search fields
// into an any type. It will return an error if the AuthMethod's public id is
// not set.
func (am *AuthMethod) convertGroupEntrySearchConf(ctx context.Context) (any, error) {
// into an *GroupEntrySearchConf type. It will return an error if the
// AuthMethod's public id is not set.
func (am *AuthMethod) convertGroupEntrySearchConf(ctx context.Context) (*GroupEntrySearchConf, error) {
const op = "ldap.(AuthMethod).convertGroupEntrySearchConf"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
@@ -272,9 +272,9 @@ func (am *AuthMethod) convertGroupEntrySearchConf(ctx context.Context) (any, err
}
// convertClientCertificate converts an embedded client certificate entry into
// an any type. It will return an error if the AuthMethod's public id is not
// set.
func (am *AuthMethod) convertClientCertificate(ctx context.Context) (any, error) {
// an *ClientCertificate type. It will return an error if the AuthMethod's
// public id is not set.
func (am *AuthMethod) convertClientCertificate(ctx context.Context) (*ClientCertificate, error) {
const op = "ldap.(AuthMethod).convertClientCertificate"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing auth method id")
@@ -287,9 +287,9 @@ func (am *AuthMethod) convertClientCertificate(ctx context.Context) (any, error)
}
// convertBindCredential converts an embedded bind credential entry into
// an any type. It will return an error if the AuthMethod's public id is not
// set.
func (am *AuthMethod) convertBindCredential(ctx context.Context) (any, error) {
// an *BindCredential type. It will return an error if the AuthMethod's public
// id is not set.
func (am *AuthMethod) convertBindCredential(ctx context.Context) (*BindCredential, error) {
const op = "ldap.(AuthMethod).convertBindCredentials"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing auth method id")
@@ -302,9 +302,9 @@ func (am *AuthMethod) convertBindCredential(ctx context.Context) (any, error) {
}
// convertDerefAliases converts an embedded deref aliases entry into
// an any type. It will return an error if the AuthMethod's public id is not
// set.
func (am *AuthMethod) convertDerefAliases(ctx context.Context) (any, error) {
// an *DerefAliases type. It will return an error if the AuthMethod's public id
// is not set.
func (am *AuthMethod) convertDerefAliases(ctx context.Context) (*DerefAliases, error) {
const op = "ldap.(AuthMethod).convertDerefAliases"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing auth method id")
@@ -317,15 +317,15 @@ func (am *AuthMethod) convertDerefAliases(ctx context.Context) (any, error) {
}
// convertAccountAttributeMaps converts the embedded account attribute maps from
// []string to []interface{} where each slice element is a *AccountAttributeMap. It
// will return an error if the AuthMethod's public id is not set or it can
// convert the account attribute maps.
func (am *AuthMethod) convertAccountAttributeMaps(ctx context.Context) ([]any, error) {
// []string to []*AccountAttributeMap. It will return an error if the
// AuthMethod's public id is not set or it can convert the account attribute
// maps.
func (am *AuthMethod) convertAccountAttributeMaps(ctx context.Context) ([]*AccountAttributeMap, error) {
const op = "ldap.(AuthMethod).convertAccountAttributeMaps"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newInterfaces := make([]any, 0, len(am.AccountAttributeMaps))
acctAttribMaps := make([]*AccountAttributeMap, 0, len(am.AccountAttributeMaps))
const (
from = 0
to = 1
@@ -343,7 +343,7 @@ func (am *AuthMethod) convertAccountAttributeMaps(ctx context.Context) ([]any, e
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
newInterfaces = append(newInterfaces, obj)
acctAttribMaps = append(acctAttribMaps, obj)
}
return newInterfaces, nil
return acctAttribMaps, nil
}
+22 -5
View File
@@ -348,9 +348,9 @@ func Test_convertValueObjects(t *testing.T) {
testCerts := []string{pem}
c, err := NewCertificate(testCtx, testPublicId, pem)
require.NoError(t, err)
testCertificates := []any{c}
testCertificates := []*Certificate{c}
testUrls := make([]any, 0, len(testLdapServers))
testUrls := make([]*Url, 0, len(testLdapServers))
for priority, uu := range TestConvertToUrls(t, testLdapServers...) {
u, err := NewUrl(testCtx, testPublicId, priority+1, uu)
require.NoError(t, err)
@@ -358,7 +358,7 @@ func Test_convertValueObjects(t *testing.T) {
}
testAttrMaps := []string{"email_address=email", "display_name=fullName"}
testAccountAttributeMaps := make([]any, 0, len(testAttrMaps))
testAccountAttributeMaps := make([]*AccountAttributeMap, 0, len(testAttrMaps))
acms, err := ParseAccountAttributeMaps(testCtx, testAttrMaps...)
require.NoError(t, err)
for _, m := range acms {
@@ -618,6 +618,23 @@ func (a converted) Less(i, j int) bool {
}
func testSortConverted(t *testing.T, c *convertedValues) {
sort.Sort(converted(c.Urls))
sort.Sort(converted(c.Certs))
t.Helper()
sort.Sort(sortableUrls(c.Urls))
sort.Sort(sortableCerts(c.Certs))
}
type sortableUrls []*Url
func (u sortableUrls) Len() int { return len(u) }
func (u sortableUrls) Swap(i, j int) { u[i], u[j] = u[j], u[i] }
func (u sortableUrls) Less(i, j int) bool {
return u[i].GetServerUrl() < u[j].GetServerUrl()
}
type sortableCerts []*Certificate
func (c sortableCerts) Len() int { return len(c) }
func (c sortableCerts) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
func (c sortableCerts) Less(i, j int) bool {
return c[i].GetCert() < c[j].GetCert()
}
@@ -68,20 +68,12 @@ func (r *Repository) CreateAuthMethod(ctx context.Context, am *AuthMethod, opt .
}
if cv.BindCredential != nil {
bc, ok := cv.BindCredential.(*BindCredential)
if !ok {
return nil, errors.New(ctx, errors.Internal, op, fmt.Sprintf("invalid type (%T) is not a bind credential", cv.BindCredential))
}
if err := bc.encrypt(ctx, dbWrapper); err != nil {
if err := cv.BindCredential.encrypt(ctx, dbWrapper); err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("failed to encrypt bind credential"))
}
}
if cv.ClientCertificate != nil {
cc, ok := cv.ClientCertificate.(*ClientCertificate)
if !ok {
return nil, errors.New(ctx, errors.Internal, op, fmt.Sprintf("invalid type (%T) is not a client certificate", cv.ClientCertificate))
}
if err := cc.encrypt(ctx, dbWrapper); err != nil {
if err := cv.ClientCertificate.encrypt(ctx, dbWrapper); err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("failed to encrypt client certificate"))
}
}
@@ -155,18 +155,42 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, am *AuthMethod, versi
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to get database wrapper"))
}
addUrls, deleteUrls, err := valueObjectChanges(ctx, origAm.PublicId, UrlVO, am.Urls, origAm.Urls, dbMask, nullFields)
au, du, err := valueObjectChanges(ctx, origAm.PublicId, UrlVO, am.Urls, origAm.Urls, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update urls"))
}
addCerts, deleteCerts, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields)
addUrls := []*Url{}
for _, u := range au {
addUrls = append(addUrls, u.(*Url))
}
deleteUrls := []*Url{}
for _, u := range du {
deleteUrls = append(deleteUrls, u.(*Url))
}
ac, dc, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update certificates"))
}
addMaps, deleteMaps, err := valueObjectChanges(ctx, origAm.PublicId, AccountAttributeMapsVO, am.AccountAttributeMaps, origAm.AccountAttributeMaps, dbMask, nullFields)
deleteCerts := []*Certificate{}
for _, c := range dc {
deleteCerts = append(deleteCerts, c.(*Certificate))
}
addCerts := []*Certificate{}
for _, c := range ac {
addCerts = append(addCerts, c.(*Certificate))
}
addM, deleteM, err := valueObjectChanges(ctx, origAm.PublicId, AccountAttributeMapsVO, am.AccountAttributeMaps, origAm.AccountAttributeMaps, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update account attribute maps"))
}
addMaps := []*AccountAttributeMap{}
for _, m := range addM {
addMaps = append(addMaps, m.(*AccountAttributeMap))
}
deleteMaps := []*AccountAttributeMap{}
for _, m := range deleteM {
deleteMaps = append(deleteMaps, m.(*AccountAttributeMap))
}
combinedMasks := append(dbMask, nullFields...)
@@ -117,18 +117,13 @@ func (r *Repository) Authenticate(ctx context.Context, authMethodId, loginName,
}
for _, attrMap := range attrMaps {
aam, ok := attrMap.(*AccountAttributeMap)
if !ok {
return nil, errors.New(ctx, errors.Internal, op, "failed to convert attribute map into AccountAttributeMap type")
}
switch aam.ToAttribute {
switch attrMap.ToAttribute {
case DefaultEmailAttribute:
emailAttr = aam.FromAttribute
emailAttr = attrMap.FromAttribute
case DefaultFullNameAttribute:
fullNameAttr = aam.FromAttribute
fullNameAttr = attrMap.FromAttribute
default:
return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("invalid to attribute %q", aam.ToAttribute))
return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("invalid to attribute %q", attrMap.ToAttribute))
}
}
+14 -14
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/auth/ldap/store/v1/ldap.proto
@@ -1942,7 +1942,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_rawDescGZIP() []byte
}
var file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_controller_storage_auth_ldap_store_v1_ldap_proto_goTypes = []interface{}{
var file_controller_storage_auth_ldap_store_v1_ldap_proto_goTypes = []any{
(*AuthMethod)(nil), // 0: controller.storage.auth.ldap.store.v1.AuthMethod
(*Url)(nil), // 1: controller.storage.auth.ldap.store.v1.Url
(*UserEntrySearchConf)(nil), // 2: controller.storage.auth.ldap.store.v1.UserEntrySearchConf
@@ -1986,7 +1986,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*AuthMethod); i {
case 0:
return &v.state
@@ -1998,7 +1998,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*Url); i {
case 0:
return &v.state
@@ -2010,7 +2010,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*UserEntrySearchConf); i {
case 0:
return &v.state
@@ -2022,7 +2022,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*GroupEntrySearchConf); i {
case 0:
return &v.state
@@ -2034,7 +2034,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*Certificate); i {
case 0:
return &v.state
@@ -2046,7 +2046,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*ClientCertificate); i {
case 0:
return &v.state
@@ -2058,7 +2058,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[6].Exporter = func(v any, i int) any {
switch v := v.(*BindCredential); i {
case 0:
return &v.state
@@ -2070,7 +2070,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[7].Exporter = func(v any, i int) any {
switch v := v.(*Account); i {
case 0:
return &v.state
@@ -2082,7 +2082,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[8].Exporter = func(v any, i int) any {
switch v := v.(*AccountAttributeMap); i {
case 0:
return &v.state
@@ -2094,7 +2094,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[9].Exporter = func(v any, i int) any {
switch v := v.(*DerefAliases); i {
case 0:
return &v.state
@@ -2106,7 +2106,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[10].Exporter = func(v any, i int) any {
switch v := v.(*ManagedGroup); i {
case 0:
return &v.state
@@ -2118,7 +2118,7 @@ func file_controller_storage_auth_ldap_store_v1_ldap_proto_init() {
return nil
}
}
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_ldap_store_v1_ldap_proto_msgTypes[11].Exporter = func(v any, i int) any {
switch v := v.(*ManagedGroupMemberAccount); i {
case 0:
return &v.state
+50 -58
View File
@@ -289,12 +289,12 @@ func (am *AuthMethod) isComplete(ctx context.Context) error {
}
type convertedValues struct {
Algs []any
Auds []any
Certs []any
ClaimsScopes []any
AccountClaimMaps []any
Prompts []any
Algs []*SigningAlg
Auds []*AudClaim
Certs []*Certificate
ClaimsScopes []*ClaimsScope
AccountClaimMaps []*AccountClaimMap
Prompts []*Prompt
}
// convertValueObjects converts the embedded value objects. It will return an
@@ -305,121 +305,113 @@ func (am *AuthMethod) convertValueObjects(ctx context.Context) (*convertedValues
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
var err error
var addAlgs, addAuds, addCerts, addScopes, addAccountClaimMaps, addPrompts []any
if addAlgs, err = am.convertSigningAlgs(ctx); err != nil {
converted := &convertedValues{}
if converted.Algs, err = am.convertSigningAlgs(ctx); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
if addAuds, err = am.convertAudClaims(ctx); err != nil {
if converted.Auds, err = am.convertAudClaims(ctx); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
if addCerts, err = am.convertCertificates(ctx); err != nil {
if converted.Certs, err = am.convertCertificates(ctx); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
if addScopes, err = am.convertClaimsScopes(ctx); err != nil {
if converted.ClaimsScopes, err = am.convertClaimsScopes(ctx); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
if addAccountClaimMaps, err = am.convertAccountClaimMaps(ctx); err != nil {
if converted.AccountClaimMaps, err = am.convertAccountClaimMaps(ctx); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
if addPrompts, err = am.convertPrompts(ctx); err != nil {
if converted.Prompts, err = am.convertPrompts(ctx); err != nil {
return nil, errors.Wrap(ctx, err, op)
}
return &convertedValues{
Algs: addAlgs,
Auds: addAuds,
Certs: addCerts,
ClaimsScopes: addScopes,
AccountClaimMaps: addAccountClaimMaps,
Prompts: addPrompts,
}, nil
return converted, nil
}
// convertSigningAlgs converts the embedded signing algorithms from []string
// to []interface{} where each slice element is a *SigningAlg. It will return an
// error if the AuthMethod's public id is not set.
func (am *AuthMethod) convertSigningAlgs(ctx context.Context) ([]any, error) {
// to []*SigningAlg. It will return an error if the AuthMethod's public id is
// not set.
func (am *AuthMethod) convertSigningAlgs(ctx context.Context) ([]*SigningAlg, error) {
const op = "oidc.(AuthMethod).convertSigningAlgs"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newInterfaces := make([]any, 0, len(am.SigningAlgs))
newAlgs := make([]*SigningAlg, 0, len(am.SigningAlgs))
for _, a := range am.SigningAlgs {
obj, err := NewSigningAlg(ctx, am.PublicId, Alg(a))
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
newInterfaces = append(newInterfaces, obj)
newAlgs = append(newAlgs, obj)
}
return newInterfaces, nil
return newAlgs, nil
}
// convertAudClaims converts the embedded audience claims from []string
// to []interface{} where each slice element is a *AudClaim. It will return an
// error if the AuthMethod's public id is not set.
func (am *AuthMethod) convertAudClaims(ctx context.Context) ([]any, error) {
// to []*AudClaim. It will return an error if the AuthMethod's public id is not
// set.
func (am *AuthMethod) convertAudClaims(ctx context.Context) ([]*AudClaim, error) {
const op = "oidc.(AuthMethod).convertAudClaims"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newInterfaces := make([]any, 0, len(am.AudClaims))
newClaims := make([]*AudClaim, 0, len(am.AudClaims))
for _, a := range am.AudClaims {
obj, err := NewAudClaim(ctx, am.PublicId, a)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
newInterfaces = append(newInterfaces, obj)
newClaims = append(newClaims, obj)
}
return newInterfaces, nil
return newClaims, nil
}
// convertCertificates converts the embedded certificates from []string
// to []interface{} where each slice element is a *Certificate. It will return an
// error if the AuthMethod's public id is not set.
func (am *AuthMethod) convertCertificates(ctx context.Context) ([]any, error) {
// to []*Certificate. It will return an error if the AuthMethod's public id is
// not set.
func (am *AuthMethod) convertCertificates(ctx context.Context) ([]*Certificate, error) {
const op = "oidc.(AuthMethod).convertCertificates"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newInterfaces := make([]any, 0, len(am.Certificates))
newCerts := make([]*Certificate, 0, len(am.Certificates))
for _, cert := range am.Certificates {
obj, err := NewCertificate(ctx, am.PublicId, cert)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
newInterfaces = append(newInterfaces, obj)
newCerts = append(newCerts, obj)
}
return newInterfaces, nil
return newCerts, nil
}
// convertClaimsScopes converts the embedded claims scopes from []string
// to []interface{} where each slice element is a *ClaimsScope. It will return an
// error if the AuthMethod's public id is not set.
func (am *AuthMethod) convertClaimsScopes(ctx context.Context) ([]any, error) {
// to []*ClaimsScope. It will return an error if the AuthMethod's public id is
// not set.
func (am *AuthMethod) convertClaimsScopes(ctx context.Context) ([]*ClaimsScope, error) {
const op = "oidc.(AuthMethod).convertClaimsScopes"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newInterfaces := make([]any, 0, len(am.ClaimsScopes))
newClaimsScopes := make([]*ClaimsScope, 0, len(am.ClaimsScopes))
for _, cs := range am.ClaimsScopes {
obj, err := NewClaimsScope(ctx, am.PublicId, cs)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
newInterfaces = append(newInterfaces, obj)
newClaimsScopes = append(newClaimsScopes, obj)
}
return newInterfaces, nil
return newClaimsScopes, nil
}
// convertAccountClaimMaps converts the embedded account claim maps from
// []string to []interface{} where each slice element is a *AccountClaimMap. It
// will return an error if the AuthMethod's public id is not set or it can
// convert the account claim maps.
func (am *AuthMethod) convertAccountClaimMaps(ctx context.Context) ([]any, error) {
// []string to []*AccountClaimMap. It will return an error if the AuthMethod's
// public id is not set or it can convert the account claim maps.
func (am *AuthMethod) convertAccountClaimMaps(ctx context.Context) ([]*AccountClaimMap, error) {
const op = "oidc.(AuthMethod).convertAccountClaimMaps"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newInterfaces := make([]any, 0, len(am.AccountClaimMaps))
newAccountClaimMaps := make([]*AccountClaimMap, 0, len(am.AccountClaimMaps))
const (
from = 0
to = 1
@@ -437,9 +429,9 @@ func (am *AuthMethod) convertAccountClaimMaps(ctx context.Context) ([]any, error
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
newInterfaces = append(newInterfaces, obj)
newAccountClaimMaps = append(newAccountClaimMaps, obj)
}
return newInterfaces, nil
return newAccountClaimMaps, nil
}
// ClaimMap defines the To and From of an oidc claim map
@@ -477,20 +469,20 @@ func ParseAccountClaimMaps(ctx context.Context, m ...string) ([]ClaimMap, error)
}
// convertPrompts converts the embedded prompts from []string
// to []interface{} where each slice element is a *Prompt. It will return an
// error if the AuthMethod's public id is not set.
func (am *AuthMethod) convertPrompts(ctx context.Context) ([]any, error) {
// to []*Prompt. It will return an error if the AuthMethod's public id is not
// set.
func (am *AuthMethod) convertPrompts(ctx context.Context) ([]*Prompt, error) {
const op = "oidc.(AuthMethod).convertPrompts"
if am.PublicId == "" {
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id")
}
newInterfaces := make([]any, 0, len(am.Prompts))
newPrompts := make([]*Prompt, 0, len(am.Prompts))
for _, a := range am.Prompts {
obj, err := NewPrompt(ctx, am.PublicId, PromptParam(a))
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
newInterfaces = append(newInterfaces, obj)
newPrompts = append(newPrompts, obj)
}
return newInterfaces, nil
return newPrompts, nil
}
+51 -30
View File
@@ -550,7 +550,7 @@ func Test_convertValueObjects(t *testing.T) {
testPublicId := "test-id"
testAlgs := []string{string(RS256), string(RS384)}
var testSigningAlgs []any
var testSigningAlgs []*SigningAlg
for _, a := range []Alg{RS256, RS384} {
obj, err := NewSigningAlg(ctx, testPublicId, Alg(a))
require.NoError(t, err)
@@ -558,7 +558,7 @@ func Test_convertValueObjects(t *testing.T) {
}
testAuds := []string{"alice", "eve"}
var testAudiences []any
var testAudiences []*AudClaim
for _, a := range testAuds {
obj, err := NewAudClaim(ctx, testPublicId, a)
require.NoError(t, err)
@@ -569,10 +569,10 @@ func Test_convertValueObjects(t *testing.T) {
testCerts := []string{pem}
c, err := NewCertificate(ctx, testPublicId, pem)
require.NoError(t, err)
testCertificates := []any{c}
testCertificates := []*Certificate{c}
testScopes := []string{"profile", "email"}
testClaimsScopes := make([]any, 0, len(testScopes))
testClaimsScopes := make([]*ClaimsScope, 0, len(testScopes))
for _, s := range testScopes {
obj, err := NewClaimsScope(ctx, testPublicId, s)
require.NoError(t, err)
@@ -580,7 +580,7 @@ func Test_convertValueObjects(t *testing.T) {
}
testClaimMaps := []string{"oid=sub", "display_name=name"}
testAccountClaimMaps := make([]any, 0, len(testClaimMaps))
testAccountClaimMaps := make([]*AccountClaimMap, 0, len(testClaimMaps))
acms, err := ParseAccountClaimMaps(ctx, testClaimMaps...)
require.NoError(t, err)
for _, m := range acms {
@@ -592,7 +592,7 @@ func Test_convertValueObjects(t *testing.T) {
}
testPrompts := []string{"consent", "select_account"}
testExpectedPrompts := make([]any, 0, len(testPrompts))
testExpectedPrompts := make([]*Prompt, 0, len(testPrompts))
for _, a := range testPrompts {
obj, err := NewPrompt(ctx, testPublicId, PromptParam(a))
require.NoError(t, err)
@@ -690,11 +690,11 @@ func Test_convertValueObjects(t *testing.T) {
} else {
want := make([]*AccountClaimMap, 0, len(tt.wantValues.AccountClaimMaps))
for _, v := range tt.wantValues.AccountClaimMaps {
want = append(want, v.(*AccountClaimMap))
want = append(want, v)
}
got := make([]*AccountClaimMap, 0, len(convertedMaps))
for _, v := range convertedMaps {
got = append(got, v.(*AccountClaimMap))
got = append(got, v)
}
sort.Slice(want, func(a, b int) bool {
return want[a].ToClaim < want[b].ToClaim
@@ -730,30 +730,51 @@ func Test_convertValueObjects(t *testing.T) {
}
}
type converted []any
type sortableAlgs []*SigningAlg
func (a converted) Len() int { return len(a) }
func (a converted) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a converted) Less(i, j int) bool {
switch a[i].(type) {
case *SigningAlg:
return a[i].(*SigningAlg).GetAlg() < a[j].(*SigningAlg).GetAlg()
case *Certificate:
return a[i].(*Certificate).GetCert() < a[j].(*Certificate).GetCert()
case *AccountClaimMap:
return a[i].(*AccountClaimMap).GetToClaim() < a[j].(*AccountClaimMap).GetToClaim()
case *AudClaim:
return a[i].(*AudClaim).GetAud() < a[j].(*AudClaim).GetAud()
case *ClaimsScope:
return a[i].(*ClaimsScope).GetScope() < a[j].(*ClaimsScope).GetScope()
}
return false
func (s sortableAlgs) Len() int { return len(s) }
func (s sortableAlgs) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sortableAlgs) Less(i, j int) bool {
return s[i].GetAlg() < s[j].GetAlg()
}
type sortableCerts []*Certificate
func (s sortableCerts) Len() int { return len(s) }
func (s sortableCerts) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sortableCerts) Less(i, j int) bool {
return s[i].GetCert() < s[j].GetCert()
}
type sortableAccountClaimMaps []*AccountClaimMap
func (s sortableAccountClaimMaps) Len() int { return len(s) }
func (s sortableAccountClaimMaps) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sortableAccountClaimMaps) Less(i, j int) bool {
return s[i].GetFromClaim()+s[i].GetToClaim() < s[j].GetFromClaim()+s[j].GetToClaim()
}
type sortableAuds []*AudClaim
func (s sortableAuds) Len() int { return len(s) }
func (s sortableAuds) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sortableAuds) Less(i, j int) bool {
return s[i].GetAud() < s[j].GetAud()
}
type sortableClaimsScopes []*ClaimsScope
func (s sortableClaimsScopes) Len() int { return len(s) }
func (s sortableClaimsScopes) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sortableClaimsScopes) Less(i, j int) bool {
return s[i].GetScope() < s[j].GetScope()
}
func testSortConverted(t *testing.T, c *convertedValues) {
sort.Sort(converted(c.Algs))
sort.Sort(converted(c.Certs))
sort.Sort(converted(c.AccountClaimMaps))
sort.Sort(converted(c.Auds))
sort.Sort(converted(c.ClaimsScopes))
t.Helper()
sort.Sort(sortableAlgs(c.Algs))
sort.Sort(sortableCerts(c.Certs))
sort.Sort(sortableAccountClaimMaps(c.AccountClaimMaps))
sort.Sort(sortableAuds(c.Auds))
sort.Sort(sortableClaimsScopes(c.ClaimsScopes))
}
@@ -155,47 +155,93 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, am *AuthMethod, versi
}
}
addAlgs, deleteAlgs, err := valueObjectChanges(ctx, origAm.PublicId, SigningAlgVO, am.SigningAlgs, origAm.SigningAlgs, dbMask, nullFields)
aa, ad, err := valueObjectChanges(ctx, origAm.PublicId, SigningAlgVO, am.SigningAlgs, origAm.SigningAlgs, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op)
}
addAlgs := []*SigningAlg{}
for _, a := range aa {
addAlgs = append(addAlgs, a.(*SigningAlg))
}
deleteAlgs := []*SigningAlg{}
for _, a := range ad {
deleteAlgs = append(deleteAlgs, a.(*SigningAlg))
}
addCerts, deleteCerts, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields)
ac, dc, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op)
}
addCerts := []*Certificate{}
for _, c := range ac {
addCerts = append(addCerts, c.(*Certificate))
}
deleteCerts := []*Certificate{}
for _, c := range dc {
deleteCerts = append(deleteCerts, c.(*Certificate))
}
addAuds, deleteAuds, err := valueObjectChanges(ctx, origAm.PublicId, AudClaimVO, am.AudClaims, origAm.AudClaims, dbMask, nullFields)
aa, ad, err = valueObjectChanges(ctx, origAm.PublicId, AudClaimVO, am.AudClaims, origAm.AudClaims, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op)
}
addAuds := []*AudClaim{}
for _, a := range aa {
addAuds = append(addAuds, a.(*AudClaim))
}
deleteAuds := []*AudClaim{}
for _, a := range ad {
deleteAuds = append(deleteAuds, a.(*AudClaim))
}
addScopes, deleteScopes, err := valueObjectChanges(ctx, origAm.PublicId, ClaimsScopesVO, am.ClaimsScopes, origAm.ClaimsScopes, dbMask, nullFields)
as, ds, err := valueObjectChanges(ctx, origAm.PublicId, ClaimsScopesVO, am.ClaimsScopes, origAm.ClaimsScopes, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op)
}
addScopes := []*ClaimsScope{}
for _, s := range as {
addScopes = append(addScopes, s.(*ClaimsScope))
}
deleteScopes := []*ClaimsScope{}
for _, s := range ds {
deleteScopes = append(deleteScopes, s.(*ClaimsScope))
}
addMaps, deleteMaps, err := valueObjectChanges(ctx, origAm.PublicId, AccountClaimMapsVO, am.AccountClaimMaps, origAm.AccountClaimMaps, dbMask, nullFields)
aacm, dacm, err := valueObjectChanges(ctx, origAm.PublicId, AccountClaimMapsVO, am.AccountClaimMaps, origAm.AccountClaimMaps, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op)
}
addMaps := []*AccountClaimMap{}
for _, m := range aacm {
addMaps = append(addMaps, m.(*AccountClaimMap))
}
deleteMaps := []*AccountClaimMap{}
for _, m := range dacm {
deleteMaps = append(deleteMaps, m.(*AccountClaimMap))
}
addPrompts, deletePrompts, err := valueObjectChanges(ctx, origAm.PublicId, PromptsVO, am.Prompts, origAm.Prompts, dbMask, nullFields)
ap, dp, err := valueObjectChanges(ctx, origAm.PublicId, PromptsVO, am.Prompts, origAm.Prompts, dbMask, nullFields)
if err != nil {
return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op)
}
addPrompts := []*Prompt{}
for _, p := range ap {
addPrompts = append(addPrompts, p.(*Prompt))
}
deletePrompts := []*Prompt{}
for _, p := range dp {
deletePrompts = append(deletePrompts, p.(*Prompt))
}
// we don't allow updates for "sub" claim maps, because we have no way to
// determine if the updated "from" claim in the map might create collisions
// with any existing account's subject.
for _, rawCm := range addMaps {
cm := rawCm.(*AccountClaimMap)
for _, cm := range addMaps {
if cm.ToClaim == string(ToSubClaim) {
return nil, db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("you cannot update account claim map %s=%s for the \"sub\" claim", cm.FromClaim, cm.ToClaim))
}
}
for _, rawCm := range deleteMaps {
cm := rawCm.(*AccountClaimMap)
for _, cm := range deleteMaps {
if cm.ToClaim == string(ToSubClaim) {
return nil, db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("you cannot update account claim map %s=%s for the \"sub\" claim", cm.FromClaim, cm.ToClaim))
}
@@ -117,7 +117,7 @@ func (r *Repository) SetManagedGroupMemberships(ctx context.Context, am *AuthMet
}
// Figure out which ones to delete and which ones we already have
toDelete := make([]any, 0, len(mgs))
toDelete := make([]*ManagedGroupMemberAccount, 0, len(mgs))
for _, currMg := range currentMemberships {
currMgId := currMg.ManagedGroupId
if newMgPublicIds[currMgId] {
@@ -161,7 +161,7 @@ func (r *Repository) SetManagedGroupMemberships(ctx context.Context, am *AuthMet
if len(newMgPublicIds) > 0 {
metadata["op-type"] = append(metadata["op-type"], oplog.OpType_OP_TYPE_CREATE.String())
addOplogMsgs := make([]*oplog.Message, 0, len(newMgPublicIds))
toAdd := make([]any, 0, len(newMgPublicIds))
toAdd := make([]*ManagedGroupMemberAccount, 0, len(newMgPublicIds))
for mgId := range newMgPublicIds {
newMg := AllocManagedGroupMemberAccount()
newMg.ManagedGroupId = mgId
+5 -5
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/auth/oidc/request/v1/request.proto
@@ -341,7 +341,7 @@ func file_controller_storage_auth_oidc_request_v1_request_proto_rawDescGZIP() []
}
var file_controller_storage_auth_oidc_request_v1_request_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_controller_storage_auth_oidc_request_v1_request_proto_goTypes = []interface{}{
var file_controller_storage_auth_oidc_request_v1_request_proto_goTypes = []any{
(*State)(nil), // 0: controller.storage.auth.oidc.request.v1.State
(*Token)(nil), // 1: controller.storage.auth.oidc.request.v1.Token
(*Wrapper)(nil), // 2: controller.storage.auth.oidc.request.v1.Wrapper
@@ -364,7 +364,7 @@ func file_controller_storage_auth_oidc_request_v1_request_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_auth_oidc_request_v1_request_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_request_v1_request_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*State); i {
case 0:
return &v.state
@@ -376,7 +376,7 @@ func file_controller_storage_auth_oidc_request_v1_request_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_request_v1_request_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_request_v1_request_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*Token); i {
case 0:
return &v.state
@@ -388,7 +388,7 @@ func file_controller_storage_auth_oidc_request_v1_request_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_request_v1_request_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_request_v1_request_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*Wrapper); i {
case 0:
return &v.state
+12 -12
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/auth/oidc/store/v1/oidc.proto
@@ -1382,7 +1382,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_rawDescGZIP() []byte
}
var file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_controller_storage_auth_oidc_store_v1_oidc_proto_goTypes = []interface{}{
var file_controller_storage_auth_oidc_store_v1_oidc_proto_goTypes = []any{
(*AuthMethod)(nil), // 0: controller.storage.auth.oidc.store.v1.AuthMethod
(*Account)(nil), // 1: controller.storage.auth.oidc.store.v1.Account
(*SigningAlg)(nil), // 2: controller.storage.auth.oidc.store.v1.SigningAlg
@@ -1422,7 +1422,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*AuthMethod); i {
case 0:
return &v.state
@@ -1434,7 +1434,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*Account); i {
case 0:
return &v.state
@@ -1446,7 +1446,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*SigningAlg); i {
case 0:
return &v.state
@@ -1458,7 +1458,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*AudClaim); i {
case 0:
return &v.state
@@ -1470,7 +1470,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*Certificate); i {
case 0:
return &v.state
@@ -1482,7 +1482,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*ClaimsScope); i {
case 0:
return &v.state
@@ -1494,7 +1494,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[6].Exporter = func(v any, i int) any {
switch v := v.(*AccountClaimMap); i {
case 0:
return &v.state
@@ -1506,7 +1506,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[7].Exporter = func(v any, i int) any {
switch v := v.(*ManagedGroup); i {
case 0:
return &v.state
@@ -1518,7 +1518,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[8].Exporter = func(v any, i int) any {
switch v := v.(*ManagedGroupMemberAccount); i {
case 0:
return &v.state
@@ -1530,7 +1530,7 @@ func file_controller_storage_auth_oidc_store_v1_oidc_proto_init() {
return nil
}
}
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_oidc_store_v1_oidc_proto_msgTypes[9].Exporter = func(v any, i int) any {
switch v := v.(*Prompt); i {
case 0:
return &v.state
+6 -6
View File
@@ -68,7 +68,7 @@ func TestAuthMethod(
require.NoError(err)
if len(opts.withAudClaims) > 0 {
newAudClaims := make([]any, 0, len(opts.withAudClaims))
newAudClaims := make([]*AudClaim, 0, len(opts.withAudClaims))
for _, a := range opts.withAudClaims {
aud, err := NewAudClaim(ctx, authMethod.PublicId, a)
require.NoError(err)
@@ -79,7 +79,7 @@ func TestAuthMethod(
require.Equal(len(opts.withAudClaims), len(authMethod.AudClaims))
}
if len(opts.withCertificates) > 0 {
newCerts := make([]any, 0, len(opts.withCertificates))
newCerts := make([]*Certificate, 0, len(opts.withCertificates))
for _, c := range opts.withCertificates {
pem, err := EncodeCertificates(ctx, c)
require.NoError(err)
@@ -92,7 +92,7 @@ func TestAuthMethod(
require.Equal(len(opts.withCertificates), len(authMethod.Certificates))
}
if len(opts.withSigningAlgs) > 0 {
newAlgs := make([]any, 0, len(opts.withSigningAlgs))
newAlgs := make([]*SigningAlg, 0, len(opts.withSigningAlgs))
for _, a := range opts.withSigningAlgs {
alg, err := NewSigningAlg(ctx, authMethod.PublicId, a)
require.NoError(err)
@@ -103,7 +103,7 @@ func TestAuthMethod(
require.Equal(len(opts.withSigningAlgs), len(authMethod.SigningAlgs))
}
if len(opts.withClaimsScopes) > 0 {
newClaimsScopes := make([]any, 0, len(opts.withClaimsScopes))
newClaimsScopes := make([]*ClaimsScope, 0, len(opts.withClaimsScopes))
for _, cs := range opts.withClaimsScopes {
s, err := NewClaimsScope(ctx, authMethod.PublicId, cs)
require.NoError(err)
@@ -114,7 +114,7 @@ func TestAuthMethod(
require.Equal(len(opts.withClaimsScopes), len(authMethod.ClaimsScopes))
}
if len(opts.withAccountClaimMap) > 0 {
newAccountClaimMaps := make([]any, 0, len(opts.withAccountClaimMap))
newAccountClaimMaps := make([]*AccountClaimMap, 0, len(opts.withAccountClaimMap))
for k, v := range opts.withAccountClaimMap {
acm, err := NewAccountClaimMap(ctx, authMethod.PublicId, k, v)
require.NoError(err)
@@ -124,7 +124,7 @@ func TestAuthMethod(
require.Equal(len(opts.withAccountClaimMap), len(authMethod.AccountClaimMaps))
}
if len(opts.withPrompts) > 0 {
newPrompts := make([]any, 0, len(opts.withPrompts))
newPrompts := make([]*Prompt, 0, len(opts.withPrompts))
for _, p := range opts.withPrompts {
prompt, err := NewPrompt(ctx, authMethod.PublicId, p)
require.NoError(err)
+4 -4
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/auth/password/store/v1/argon2.proto
@@ -374,7 +374,7 @@ func file_controller_storage_auth_password_store_v1_argon2_proto_rawDescGZIP() [
}
var file_controller_storage_auth_password_store_v1_argon2_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_controller_storage_auth_password_store_v1_argon2_proto_goTypes = []interface{}{
var file_controller_storage_auth_password_store_v1_argon2_proto_goTypes = []any{
(*Argon2Configuration)(nil), // 0: controller.storage.auth.password.store.v1.Argon2Configuration
(*Argon2Credential)(nil), // 1: controller.storage.auth.password.store.v1.Argon2Credential
(*timestamp.Timestamp)(nil), // 2: controller.storage.timestamp.v1.Timestamp
@@ -396,7 +396,7 @@ func file_controller_storage_auth_password_store_v1_argon2_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_auth_password_store_v1_argon2_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_password_store_v1_argon2_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*Argon2Configuration); i {
case 0:
return &v.state
@@ -408,7 +408,7 @@ func file_controller_storage_auth_password_store_v1_argon2_proto_init() {
return nil
}
}
file_controller_storage_auth_password_store_v1_argon2_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_password_store_v1_argon2_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*Argon2Credential); i {
case 0:
return &v.state
+5 -5
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/auth/password/store/v1/password.proto
@@ -477,7 +477,7 @@ func file_controller_storage_auth_password_store_v1_password_proto_rawDescGZIP()
}
var file_controller_storage_auth_password_store_v1_password_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_controller_storage_auth_password_store_v1_password_proto_goTypes = []interface{}{
var file_controller_storage_auth_password_store_v1_password_proto_goTypes = []any{
(*AuthMethod)(nil), // 0: controller.storage.auth.password.store.v1.AuthMethod
(*Account)(nil), // 1: controller.storage.auth.password.store.v1.Account
(*Credential)(nil), // 2: controller.storage.auth.password.store.v1.Credential
@@ -501,7 +501,7 @@ func file_controller_storage_auth_password_store_v1_password_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_auth_password_store_v1_password_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_password_store_v1_password_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*AuthMethod); i {
case 0:
return &v.state
@@ -513,7 +513,7 @@ func file_controller_storage_auth_password_store_v1_password_proto_init() {
return nil
}
}
file_controller_storage_auth_password_store_v1_password_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_password_store_v1_password_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*Account); i {
case 0:
return &v.state
@@ -525,7 +525,7 @@ func file_controller_storage_auth_password_store_v1_password_proto_init() {
return nil
}
}
file_controller_storage_auth_password_store_v1_password_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_password_store_v1_password_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*Credential); i {
case 0:
return &v.state
@@ -34,6 +34,7 @@ import (
type fakeReader struct {
db.Reader
}
type fakeWriter struct {
db.Writer
}
+3 -3
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/auth/store/v1/account.proto
@@ -142,7 +142,7 @@ func file_controller_storage_auth_store_v1_account_proto_rawDescGZIP() []byte {
}
var file_controller_storage_auth_store_v1_account_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_controller_storage_auth_store_v1_account_proto_goTypes = []interface{}{
var file_controller_storage_auth_store_v1_account_proto_goTypes = []any{
(*Account)(nil), // 0: controller.storage.auth.store.v1.Account
}
var file_controller_storage_auth_store_v1_account_proto_depIdxs = []int32{
@@ -159,7 +159,7 @@ func file_controller_storage_auth_store_v1_account_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_auth_store_v1_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_store_v1_account_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*Account); i {
case 0:
return &v.state
+4 -4
View File
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: controller/storage/auth/store/v1/auth_method.proto
@@ -199,7 +199,7 @@ func file_controller_storage_auth_store_v1_auth_method_proto_rawDescGZIP() []byt
}
var file_controller_storage_auth_store_v1_auth_method_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_controller_storage_auth_store_v1_auth_method_proto_goTypes = []interface{}{
var file_controller_storage_auth_store_v1_auth_method_proto_goTypes = []any{
(*AuthMethod)(nil), // 0: controller.storage.auth.store.v1.AuthMethod
(*AuthAccount)(nil), // 1: controller.storage.auth.store.v1.AuthAccount
}
@@ -217,7 +217,7 @@ func file_controller_storage_auth_store_v1_auth_method_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_auth_store_v1_auth_method_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_store_v1_auth_method_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*AuthMethod); i {
case 0:
return &v.state
@@ -229,7 +229,7 @@ func file_controller_storage_auth_store_v1_auth_method_proto_init() {
return nil
}
}
file_controller_storage_auth_store_v1_auth_method_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_controller_storage_auth_store_v1_auth_method_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*AuthAccount); i {
case 0:
return &v.state