Help us shape the future of Go! Take the 2026 Go Developer Survey

application

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package application is the Portal Backend's consumer application bounded context: applications, application submissions, their IdP clients and PDP allow-lists, and the application API.

Index

Constants

View Source
const (
	TemplateIDM2M = "m2m-application"
)

IDP Application Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	ApplicationID          string               `gorm:"primarykey;column:application_id" json:"applicationId"`
	ApplicationName        string               `gorm:"column:application_name;not null" json:"applicationName"`
	ApplicationDescription *string              `gorm:"column:application_description" json:"applicationDescription,omitempty"`
	SelectedFields         SelectedFieldRecords `gorm:"column:selected_fields;type:jsonb;not null" json:"selectedFields"`
	MemberID               string               `gorm:"column:member_id;not null" json:"memberId"`
	Version                string               `gorm:"column:version;not null" json:"version"`
	IdpApplicationID       *string              `gorm:"column:idp_application_id" json:"idpApplicationId,omitempty"` // Until the data migration is done this can be nullable
	IdpClientID            *string              `gorm:"column:idp_client_id" json:"idpClientId,omitempty"`           // Until the data migration is done this can be nullable
	kernel.BaseModel

	// Relationships
	Member member.Member `gorm:"foreignKey:MemberID;references:MemberID" json:"member"`
}

Application represents the consumer_applications table

func (Application) TableName

func (Application) TableName() string

TableName sets the table name for GORM

type ApplicationResponse

type ApplicationResponse struct {
	ApplicationID          string                       `json:"applicationId"`
	ApplicationName        string                       `json:"applicationName"`
	ApplicationDescription *string                      `json:"applicationDescription,omitempty"`
	SelectedFields         []policy.SelectedFieldRecord `json:"selectedFields"`
	MemberID               string                       `json:"memberId"`
	Version                string                       `json:"version"`
	IdpApplicationID       *string                      `json:"idpApplicationId,omitempty"`
	IdpClientID            *string                      `json:"idpClientId,omitempty"`
	// IdpClientSecret is only set in the response that created the IDP client.
	// Portal Backend doesn't store it, and ThunderID doesn't return it again.
	IdpClientSecret *string `json:"idpClientSecret,omitempty"`
	CreatedAt       string  `json:"createdAt"`
	UpdatedAt       string  `json:"updatedAt"`
}

type ApplicationSubmission

type ApplicationSubmission struct {
	SubmissionID           string               `gorm:"primarykey;column:submission_id" json:"submissionId"`
	PreviousApplicationID  *string              `gorm:"column:previous_application_id" json:"previousApplicationId,omitempty"`
	ApplicationName        string               `gorm:"column:application_name;not null" json:"applicationName"`
	ApplicationDescription *string              `gorm:"column:application_description" json:"applicationDescription,omitempty"`
	SelectedFields         SelectedFieldRecords `gorm:"column:selected_fields;type:jsonb;not null" json:"selectedFields"`
	MemberID               string               `gorm:"column:member_id;not null" json:"memberId"`
	Status                 string               `gorm:"column:status;not null" json:"status"`
	Review                 *string              `gorm:"column:review" json:"review,omitempty"`
	kernel.BaseModel

	// Relationships
	Member              member.Member `gorm:"foreignKey:MemberID;references:MemberID" json:"member"`
	PreviousApplication *Application  `gorm:"foreignKey:PreviousApplicationID;references:ApplicationID" json:"previousApplication,omitempty"`
}

ApplicationSubmission represents the consumer_application_submissions table

func (ApplicationSubmission) TableName

func (ApplicationSubmission) TableName() string

TableName sets the table name for GORM

type ApplicationSubmissionResponse

type ApplicationSubmissionResponse struct {
	SubmissionID           string                       `json:"submissionId"`
	PreviousApplicationID  *string                      `json:"previousApplicationId,omitempty"`
	ApplicationName        string                       `json:"applicationName"`
	ApplicationDescription *string                      `json:"applicationDescription,omitempty"`
	SelectedFields         []policy.SelectedFieldRecord `json:"selectedFields"`
	MemberID               string                       `json:"memberId"`
	Status                 string                       `json:"status"`
	CreatedAt              string                       `json:"createdAt"`
	UpdatedAt              string                       `json:"updatedAt"`
	Review                 *string                      `json:"review,omitempty"`
}

type CreateApplicationRequest

type CreateApplicationRequest struct {
	ApplicationName        string                       `json:"applicationName" validate:"required"`
	ApplicationDescription *string                      `json:"applicationDescription,omitempty"`
	SelectedFields         []policy.SelectedFieldRecord `json:"selectedFields" validate:"required,min=1"`
	MemberID               string                       `json:"memberId" validate:"required"`
	// IdpApplicationID and IdpClientID let a caller register an application whose
	// OAuth2 client was already provisioned directly in the IDP (e.g. manually via
	// ThunderID's console). When both are set, creation skips calling the IDP
	// entirely and uses these values as-is. Must be provided together (both or
	// neither) - a single field alone is rejected.
	IdpApplicationID *string `json:"idpApplicationId,omitempty"`
	IdpClientID      *string `json:"idpClientId,omitempty"`
}

CreateApplicationRequest creates a new consumer application

type CreateApplicationSubmissionRequest

type CreateApplicationSubmissionRequest struct {
	ApplicationName        string                       `json:"applicationName" validate:"required"`
	ApplicationDescription *string                      `json:"applicationDescription,omitempty"`
	SelectedFields         []policy.SelectedFieldRecord `json:"selectedFields" validate:"required,min=1"`
	PreviousApplicationID  *string                      `json:"previousApplicationId,omitempty"`
	MemberID               string                       `json:"memberId" validate:"required"`
}

CreateApplicationSubmissionRequest Consumer Application Submission DTOs

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles the application and application submission HTTP API

func NewHandler

func NewHandler(service *Service) *Handler

NewHandler creates a new application Handler

func (*Handler) CreateApplication

func (h *Handler) CreateApplication(w http.ResponseWriter, r *http.Request)

CreateApplication handles POST /api/v1/applications

func (*Handler) CreateApplicationSubmission

func (h *Handler) CreateApplicationSubmission(w http.ResponseWriter, r *http.Request)

CreateApplicationSubmission handles POST /api/v1/application-submissions

func (*Handler) GetAllApplicationSubmissions

func (h *Handler) GetAllApplicationSubmissions(w http.ResponseWriter, r *http.Request)

GetAllApplicationSubmissions handles GET /api/v1/application-submissions

func (*Handler) GetAllApplications

func (h *Handler) GetAllApplications(w http.ResponseWriter, r *http.Request)

GetAllApplications handles GET /api/v1/applications

func (*Handler) GetApplication

func (h *Handler) GetApplication(w http.ResponseWriter, r *http.Request)

GetApplication handles GET /api/v1/applications/{applicationId}

func (*Handler) GetApplicationSubmission

func (h *Handler) GetApplicationSubmission(w http.ResponseWriter, r *http.Request)

GetApplicationSubmission handles GET /api/v1/application-submissions/{submissionId}

func (*Handler) UpdateApplication

func (h *Handler) UpdateApplication(w http.ResponseWriter, r *http.Request)

UpdateApplication handles PUT /api/v1/applications/{applicationId}

func (*Handler) UpdateApplicationPolicy

func (h *Handler) UpdateApplicationPolicy(w http.ResponseWriter, r *http.Request)

UpdateApplicationPolicy handles PUT /api/v1/applications/{applicationId}/policy

func (*Handler) UpdateApplicationSubmission

func (h *Handler) UpdateApplicationSubmission(w http.ResponseWriter, r *http.Request)

UpdateApplicationSubmission handles PUT /api/v1/application-submissions/{submissionId}

type SelectedFieldRecords

type SelectedFieldRecords []policy.SelectedFieldRecord

SelectedFieldRecords represents an array of policy.SelectedFieldRecord with custom scanning

func (SelectedFieldRecords) GormDataType

func (SelectedFieldRecords) GormDataType() string

GormDataType gorm common data type

func (SelectedFieldRecords) GormValue

func (sfr SelectedFieldRecords) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

GormValue implements the GormValuerInterface

func (*SelectedFieldRecords) Scan

func (sfr *SelectedFieldRecords) Scan(value interface{}) error

Scan implements the sql.Scanner interface for SelectedFieldRecords

func (*SelectedFieldRecords) Value

func (sfr *SelectedFieldRecords) Value() (driver.Value, error)

Value implements the driver.Valuer interface for SelectedFieldRecords

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles application-related operations

func NewService

func NewService(db *gorm.DB, pdpService *policy.Client, idp idp.ApplicationManager) *Service

NewService creates a new application service

func (*Service) CreateApplication

func (s *Service) CreateApplication(ctx context.Context, req *CreateApplicationRequest) (*ApplicationResponse, error)

CreateApplication creates a new application. Unless the caller supplies its IDP client, the application's OAuth2 client is created in the IDP, in the owning member's organization unit, and its client secret is returned once in the response. If req.IdpApplicationID and req.IdpClientID are both set, the caller has already provisioned the OAuth2 client directly in the IDP - IDP creation is skipped and those values are used as-is.

func (*Service) CreateApplicationSubmission

func (s *Service) CreateApplicationSubmission(ctx context.Context, req *CreateApplicationSubmissionRequest) (*ApplicationSubmissionResponse, error)

CreateApplicationSubmission creates a new application submission

func (*Service) GetApplication

func (s *Service) GetApplication(ctx context.Context, applicationID string) (*ApplicationResponse, error)

GetApplication retrieves an application by ID

func (*Service) GetApplicationSubmission

func (s *Service) GetApplicationSubmission(ctx context.Context, submissionID string) (*ApplicationSubmissionResponse, error)

GetApplicationSubmission retrieves an application submission by ID

func (*Service) GetApplicationSubmissions

func (s *Service) GetApplicationSubmissions(ctx context.Context, MemberID *string, statusFilter *[]string) ([]ApplicationSubmissionResponse, error)

GetApplicationSubmissions retrieves all application submissions and filters by member ID if provided

func (*Service) GetApplications

func (s *Service) GetApplications(ctx context.Context, MemberID *string) ([]ApplicationResponse, error)

GetApplications retrieves all applications and filters by member ID if provided

func (*Service) UpdateApplication

func (s *Service) UpdateApplication(ctx context.Context, applicationID string, req *UpdateApplicationRequest) (*ApplicationResponse, error)

UpdateApplication updates an existing application

func (*Service) UpdateApplicationPolicy

func (s *Service) UpdateApplicationPolicy(ctx context.Context, applicationID string, req *UpdateApplicationPolicyRequest) (*ApplicationResponse, error)

UpdateApplicationPolicy replaces an existing application's allow-list in the PDP and persists the resulting selected fields on the application record.

func (*Service) UpdateApplicationSubmission

func (s *Service) UpdateApplicationSubmission(ctx context.Context, submissionID string, req *UpdateApplicationSubmissionRequest) (*ApplicationSubmissionResponse, error)

UpdateApplicationSubmission updates an existing application submission

type UpdateApplicationPolicyRequest

type UpdateApplicationPolicyRequest struct {
	SelectedFields []policy.SelectedFieldRecord `json:"selectedFields" validate:"required,min=1"`
	GrantDuration  *policy.GrantDurationType    `json:"grantDuration,omitempty" validate:"omitempty,grant_duration_type_enum"`
}

UpdateApplicationPolicyRequest replaces an existing application's allow-list (its requested schema fields and their PDP grant duration).

type UpdateApplicationRequest

type UpdateApplicationRequest struct {
	ApplicationName        *string `json:"applicationName,omitempty"`
	ApplicationDescription *string `json:"applicationDescription,omitempty"`
	Version                *string `json:"version,omitempty"`
}

UpdateApplicationRequest updates an existing consumer application

type UpdateApplicationSubmissionRequest

type UpdateApplicationSubmissionRequest struct {
	ApplicationName        *string                       `json:"applicationName,omitempty"`
	ApplicationDescription *string                       `json:"applicationDescription,omitempty"`
	SelectedFields         *[]policy.SelectedFieldRecord `json:"selectedFields,omitempty"`
	Status                 *string                       `json:"status,omitempty"`
	PreviousApplicationID  *string                       `json:"previousApplicationId,omitempty"`
	Review                 *string                       `json:"review,omitempty"`
}

UpdateApplicationSubmissionRequest updates the status of a consumer application submission

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL