func (api WorkerAPI) AddOidcProvider(requestInfo RequestInfo, name string, path string, issuerURL string, oidcClients []string) (*OidcProvider, error) {
	if !IsValidName(name) {
		return nil, &Error{
			Code:    INVALID_PARAMETER_ERROR,
			Message: fmt.Sprintf("Invalid parameter: name %v", name),
		}
	}
	if !IsValidPath(path) {
		return nil, &Error{
			Code:    INVALID_PARAMETER_ERROR,
			Message: fmt.Sprintf("Invalid parameter: path %v", path),
		}
	}
	if _, err := url.ParseRequestURI(issuerURL); err != nil {
		return nil, &Error{
			Code:    INVALID_PARAMETER_ERROR,
			Message: fmt.Sprintf("Invalid parameter: issuerUrl %v", issuerURL),
		}
	}
	err := AreValidOidcClientNames(oidcClients)
	if err != nil {
		apiError := err.(*Error)
		return nil, &Error{
			Code:    INVALID_PARAMETER_ERROR,
			Message: apiError.Message,
		}
	}
	oidcProvider := createOidcProvider(name, path, issuerURL, oidcClients)
	oidcProvidersFiltered, err := api.GetAuthorizedOidcProviders(requestInfo, oidcProvider.Urn, AUTH_OIDC_ACTION_CREATE_PROVIDER, []OidcProvider{oidcProvider})
	if err != nil {
		return nil, err
	}
	if len(oidcProvidersFiltered) < 1 {
		return nil, &Error{
			Code: UNAUTHORIZED_RESOURCES_ERROR,
			Message: fmt.Sprintf("User with externalId %v is not allowed to access to resource %v",
				requestInfo.Identifier, oidcProvider.Urn),
		}
	}
	_, err = api.AuthOidcRepo.GetOidcProviderByName(name)
	if err != nil {
		dbError := err.(*database.Error)
		switch dbError.Code {
		case database.AUTH_OIDC_PROVIDER_NOT_FOUND:
			createdOidcProvider, err := api.AuthOidcRepo.AddOidcProvider(oidcProvider)
			if err != nil {
				dbError := err.(*database.Error)
				return nil, &Error{
					Code:    UNKNOWN_API_ERROR,
					Message: dbError.Message,
				}
			}
			LogOperation(requestInfo.RequestID, requestInfo.Identifier, fmt.Sprintf("OIDC provider created %+v", createdOidcProvider))
			return createdOidcProvider, nil
		default:  
			return nil, &Error{
				Code:    UNKNOWN_API_ERROR,
				Message: dbError.Message,
			}
		}
	} else {  
		return nil, &Error{
			Code:    AUTH_OIDC_PROVIDER_ALREADY_EXIST,
			Message: fmt.Sprintf("Unable to create OIDC provider, OIDC provider with name %v already exist", name),
		}
	}
}
AUTHENTICATOR OIDC API IMPLEMENTATION
package api
import (
	"fmt"
	"net/url"
	"time"
	"github.com/Tecsisa/foulkon/database"
	"github.com/satori/go.uuid"
)
type OidcProvider struct {
	ID          string       `json:"id,omitempty"`
	Name        string       `json:"name,omitempty"`
	Path        string       `json:"path,omitempty"`
	Urn         string       `json:"urn,omitempty"`
	CreateAt    time.Time    `json:"createAt,omitempty"`
	UpdateAt    time.Time    `json:"updateAt,omitempty"`
	IssuerURL   string       `json:"issuerUrl,omitempty"`
	OidcClients []OidcClient `json:"clients,omitempty"`
}
type OidcClient struct {
	Name string `json:"name,omitempty"`
}
func (op OidcProvider) String() string {
	return fmt.Sprintf("[id: %v, name: %v, path: %v, urn: %v, createAt: %v, updateAt: %v, issuerUrl: %v, clients: %v]",
		op.ID, op.Name, op.Path, op.Urn, op.CreateAt.Format("2006-01-02 15:04:05 MST"),
		op.UpdateAt.Format("2006-01-02 15:04:05 MST"), op.IssuerURL, op.OidcClients)
}
func (op OidcClient) String() string {
	return fmt.Sprintf("name: %v", op.Name)
}
func (op OidcProvider) GetUrn() string {
	return op.Urn
}