Documentation
¶
Overview ¶
Package openplatform owns approved applications and separately consented business grants.
Index ¶
- Variables
- func OpenAPI() []byte
- type Acknowledgement
- type AppRecord
- type Application
- type ApplicationInput
- type AuthorizationResult
- type CatalogItem
- type Consent
- type ConsentDecision
- type ConsentInput
- type ConsentRecord
- type Credential
- type Data
- type Grant
- type GrantRecord
- type Notice
- type Page
- type Policy
- type Principal
- type Profile
- type QQBinding
- type Query
- type Repository
- type ReviewInput
- type ReviewItem
- type RevokeInput
- type ScheduleItem
- type ScheduleMeeting
- type School
- type Service
- func (s *Service) Acknowledge(ctx context.Context, p Principal, app, secret, id, key string, ...) (Notice, error)
- func (s *Service) Application(ctx context.Context, p Principal, id string) (Application, error)
- func (s *Service) Applications(ctx context.Context, p Principal, admin bool, after string, limit int) (Page[Application], error)
- func (s *Service) Apply(ctx context.Context, p Principal, id, key string, in ApplicationInput) (Application, error)
- func (s *Service) CloseAccount(ctx context.Context, owner, closureID string) error
- func (s *Service) Consent(ctx context.Context, p Principal, id string) (Consent, error)
- func (s *Service) Decide(ctx context.Context, p Principal, id, key string, in ConsentDecision) (AuthorizationResult, error)
- func (s *Service) Exchange(ctx context.Context, in TokenInput) (Token, error)
- func (s *Service) Grants(ctx context.Context, p Principal, after string, limit int) (Page[Grant], error)
- func (s *Service) Notices(ctx context.Context, p Principal, app, secret, after string, limit int) (Page[Notice], error)
- func (s *Service) PrepareConsent(ctx context.Context, p Principal, key string, in ConsentInput) (Consent, error)
- func (s *Service) Read(ctx context.Context, token, scope string, q Query) (Data, error)
- func (s *Service) Review(ctx context.Context, p Principal, id, key string, in ReviewInput) (Application, error)
- func (s *Service) Revoke(ctx context.Context, p Principal, id, key string, in RevokeInput) (Grant, error)
- func (s *Service) RotateCredential(ctx context.Context, p Principal, id, key string, revision int64) (Credential, error)
- func (s *Service) Validate() error
- func (s *Service) Work(ctx context.Context, limit int) (int, error)
- type Source
- type StudentStatus
- type Token
- type TokenInput
- type TokenRecord
- type Transaction
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInput = errors.New("invalid_input") ErrUnauthenticated = errors.New("unauthenticated") ErrForbidden = errors.New("forbidden") ErrNotFound = errors.New("not_found") ErrConflict = errors.New("conflict") ErrQuota = errors.New("quota_exceeded") ErrClient = errors.New("invalid_client") )
View Source
var Scopes = []string{"student_status", "schools", "qq_binding", "profile", "schedule", "catalog", "public_reviews"}
Functions ¶
Types ¶
type Acknowledgement ¶
type AppRecord ¶
type AppRecord struct {
View Application
Owner, SecretHash string
}
type Application ¶
type Application struct {
ID string `json:"id"`
Name string `json:"name"`
Purpose string `json:"purpose"`
RedirectURIs []string `json:"redirect_uris"`
RequestedScopes []string `json:"requested_scopes"`
ApprovedScopes []string `json:"approved_scopes"`
ClientType string `json:"client_type"`
State string `json:"state"`
Note string `json:"note"`
Revision int64 `json:"revision"`
CredentialRevision int64 `json:"credential_revision"`
Policy Policy `json:"policy"`
CreatedAt time.Time `json:"created_at"`
}
type ApplicationInput ¶
type AuthorizationResult ¶
type AuthorizationResult struct {
RedirectURI string `json:"redirect_uri"`
}
type CatalogItem ¶
type CatalogItem struct {
ID string `json:"id"`
Kind string `json:"kind"`
SchoolID string `json:"school_id"`
Name string `json:"name"`
CourseID string `json:"course_id,omitempty"`
TermID string `json:"term_id,omitempty"`
DepartmentID string `json:"department_id,omitempty"`
Biography string `json:"biography,omitempty"`
Revision int64 `json:"revision"`
}
type ConsentDecision ¶
type ConsentInput ¶
type ConsentRecord ¶
type Credential ¶
type Data ¶
type Data struct {
Subject string `json:"subject"`
Scope string `json:"scope"`
StudentStatus *StudentStatus `json:"student_status,omitempty"`
Schools *[]School `json:"schools,omitempty"`
QQBinding *QQBinding `json:"qq_binding,omitempty"`
Profile *Profile `json:"profile,omitempty"`
Schedule *[]ScheduleItem `json:"schedule,omitempty"`
Catalog *[]CatalogItem `json:"catalog,omitempty"`
Reviews *[]ReviewItem `json:"public_reviews,omitempty"`
Next string `json:"next,omitempty"`
}
Data uses closed projections so a provider cannot accidentally return raw credentials or verification material.
type GrantRecord ¶
type Notice ¶
type Notice struct {
Sequence int64 `json:"sequence"`
ID string `json:"id"`
AppID string `json:"app_id"`
Subject string `json:"subject"`
Scopes []string `json:"scopes"`
Reason string `json:"reason"`
CreatedAt time.Time `json:"created_at"`
SeenAt *time.Time `json:"seen_at,omitempty"`
Acknowledgement string `json:"acknowledgement,omitempty"`
Note string `json:"note,omitempty"`
AcknowledgedAt *time.Time `json:"acknowledged_at,omitempty"`
}
type Repository ¶
type Repository interface {
Transaction(context.Context, string, string, func(Transaction) error) error
LocateConsent(context.Context, string) (ConsentRecord, error)
LocateCode(context.Context, string) (ConsentRecord, error)
LocateToken(context.Context, string) (TokenRecord, GrantRecord, error)
LocateGrant(context.Context, string) (GrantRecord, error)
WorkCandidates(context.Context, time.Time, int) ([]GrantRecord, error)
}
type ReviewInput ¶
type ReviewItem ¶
type RevokeInput ¶
type ScheduleItem ¶
type ScheduleItem struct {
ID string `json:"id"`
CourseID string `json:"course_id"`
CourseName string `json:"course_name"`
TermID string `json:"term_id"`
ClassID string `json:"class_id"`
Meetings []ScheduleMeeting `json:"meetings"`
FetchedAt time.Time `json:"fetched_at"`
Active bool `json:"active"`
}
type ScheduleMeeting ¶
type Service ¶
type Service struct {
Repo Repository
Source Source
Now func() time.Time
Random io.Reader
CodeKey []byte
Issuer string
}
func (*Service) Acknowledge ¶
func (*Service) Application ¶
func (*Service) Applications ¶
func (*Service) Apply ¶
func (s *Service) Apply(ctx context.Context, p Principal, id, key string, in ApplicationInput) (Application, error)
func (*Service) CloseAccount ¶
CloseAccount installs a permanent grant-owner fence and application epochs in the same transaction. It is a trusted module port; there is no HTTP route that accepts another account key.
func (*Service) Decide ¶
func (s *Service) Decide(ctx context.Context, p Principal, id, key string, in ConsentDecision) (AuthorizationResult, error)
func (*Service) PrepareConsent ¶
func (*Service) Review ¶
func (s *Service) Review(ctx context.Context, p Principal, id, key string, in ReviewInput) (Application, error)
func (*Service) RotateCredential ¶
type Source ¶
Source receives only the verified grant owner; content sources must enforce current admission.
type StudentStatus ¶
type TokenInput ¶
type TokenInput struct{ GrantType, ClientID, RedirectURI, Code, Verifier, ClientSecret string }
type TokenRecord ¶
type Transaction ¶
type Transaction interface {
Closed(string) (bool, error)
CloseOwner(string, string) error
App(string) (AppRecord, error)
Apps(string, bool, string, int) ([]AppRecord, error)
SaveApp(AppRecord) error
CountApps(string) (int, error)
SuspendOwnedApps(string) error
Consent(string) (ConsentRecord, error)
PendingConsents(string, time.Time) (int, error)
SaveConsent(ConsentRecord) error
Grant(string) (GrantRecord, error)
OwnerGrant(string, string) (GrantRecord, error)
Grants(string, string, int) ([]GrantRecord, error)
SaveGrant(GrantRecord) error
Token(string) (TokenRecord, error)
SaveToken(TokenRecord) error
Quota(string, string, int) error
Notice(string) (Notice, error)
Notices(string, string, int) ([]Notice, error)
SaveNotice(Notice) error
Replay(string, string) (string, json.RawMessage, error)
SaveReplay(string, string, string, json.RawMessage) error
Event(string, string, string, string) error
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.