Documentation
¶
Index ¶
- Constants
- func ToPermissions(ps []string) []permission.Permission
- func ValidityDaysOrDefault(v *int) int
- type CurrentUserResponse
- type GroupMemberRequest
- type GroupMemberResponse
- type GroupMemberUpdate
- type GroupRequest
- type GroupResponse
- type PermissionResponse
- type ServiceAccountCreate
- type ServiceAccountResponse
- type ServiceAccountTokenRequest
- type ServiceAccountTokenResponse
- type ServiceAccountUpdate
- type UserAccountResponse
- type UserAdminUpdate
- type UserRegistration
- type UserResponse
- type UserStatusUpdate
Constants ¶
const ( DefaultServiceAccountValidityDays = 90 MaxServiceAccountValidityDays = 365 )
Token validity bounds, in days. A token always expires; the longest an admin may make one live is a year, after which it has to be renewed or regenerated.
Variables ¶
This section is empty.
Functions ¶
func ToPermissions ¶
func ToPermissions(ps []string) []permission.Permission
ToPermissions converts validated names to permissions, dropping duplicates.
func ValidityDaysOrDefault ¶
ValidityDaysOrDefault returns v, or the default when v is nil.
Types ¶
type CurrentUserResponse ¶
type CurrentUserResponse struct {
UserID string `json:"userId"`
// Status is ACTIVE for the root account and service accounts, whose standing is
// not kept on a user record.
Status string `json:"status"`
Authorities []string `json:"authorities"`
// Permissions is what the caller's roles grant, sorted. A client can use it to hide
// what the caller cannot do; the server enforces it regardless.
Permissions []string `json:"permissions"`
Admin bool `json:"admin"`
User *UserAccountResponse `json:"user"`
}
CurrentUserResponse describes the caller: their user record, if they have one, and what the server decided about them on this request.
type GroupMemberRequest ¶
type GroupMemberRequest struct {
UserID string `json:"userId"`
GroupRole *model.GroupRole `json:"groupRole"`
GroupMemberStatus *model.GroupMemberStatus `json:"groupMemberStatus"`
}
GroupMemberRequest adds a user to a group.
Role and status are optional: an omitted role admits a plain MEMBER, and an omitted status admits them as ACTIVE. Both default rather than erroring, because the common call is "add this person to my group".
func (*GroupMemberRequest) Role ¶
func (r *GroupMemberRequest) Role() model.GroupRole
Role returns the requested role, defaulting to MEMBER.
func (*GroupMemberRequest) Status ¶
func (r *GroupMemberRequest) Status() model.GroupMemberStatus
Status returns the requested status, defaulting to ACTIVE.
func (*GroupMemberRequest) Validate ¶
func (r *GroupMemberRequest) Validate() []httpx.FieldError
Validate implements httpx.Validator.
type GroupMemberResponse ¶
type GroupMemberResponse struct {
GroupID string `json:"groupId"`
UserID string `json:"userId"`
GroupRole model.GroupRole `json:"groupRole"`
GroupMemberStatus model.GroupMemberStatus `json:"groupMemberStatus"`
}
GroupMemberResponse is the read model for one membership.
func ToGroupMemberResponse ¶
func ToGroupMemberResponse(m *model.GroupMember) GroupMemberResponse
func ToGroupMemberResponses ¶
func ToGroupMemberResponses(members []model.GroupMember) []GroupMemberResponse
type GroupMemberUpdate ¶
type GroupMemberUpdate struct {
GroupRole *model.GroupRole `json:"groupRole"`
GroupMemberStatus *model.GroupMemberStatus `json:"groupMemberStatus"`
}
GroupMemberUpdate changes an existing membership.
Both fields are optional and an omitted one is left as it stands, so a caller can suspend a member without having to restate their role. The user is identified by the path, not the body: a membership cannot be moved to a different user by editing it.
func (*GroupMemberUpdate) Apply ¶
func (r *GroupMemberUpdate) Apply(m *model.GroupMember)
Apply writes the fields the caller actually supplied onto m.
func (*GroupMemberUpdate) Validate ¶
func (r *GroupMemberUpdate) Validate() []httpx.FieldError
Validate implements httpx.Validator.
type GroupRequest ¶
type GroupRequest struct {
GroupName string `json:"groupName"`
}
GroupRequest is the create/update payload for a group.
There is no owner field: ownership comes from the access token and is immutable, so a group can neither be created on someone else's behalf nor handed over by editing it.
func (*GroupRequest) Validate ¶
func (r *GroupRequest) Validate() []httpx.FieldError
Validate implements httpx.Validator.
type GroupResponse ¶
type GroupResponse struct {
GroupID string `json:"groupId"`
GroupName *string `json:"groupName,omitempty"`
OwnerID *string `json:"ownerId,omitempty"`
CreatedAt int64 `json:"createdAt"`
}
GroupResponse is the read model for a group.
Members are not inlined: a group's membership is read through /api/v1/groups/{groupId}/members, which keeps a large group's listing from being dragged into every response that merely names it.
func ToGroupResponse ¶
func ToGroupResponse(g *model.Group) GroupResponse
func ToGroupResponses ¶
func ToGroupResponses(groups []model.Group) []GroupResponse
type PermissionResponse ¶
type PermissionResponse struct {
Permission string `json:"permission"`
Description string `json:"description"`
// GrantableToServiceAccount is false for the permissions no service account may
// hold, which a client should not offer.
GrantableToServiceAccount bool `json:"grantableToServiceAccount"`
}
PermissionResponse describes one permission, so a client can offer them for granting.
type ServiceAccountCreate ¶
type ServiceAccountCreate struct {
// Name becomes the account's user id as "sa:<name>".
Name string `json:"name"`
DisplayName *string `json:"displayName"`
Description *string `json:"description"`
Email *string `json:"email"`
// ValidityDays is how long the first token lives. Defaults to 90.
ValidityDays *int `json:"validityDays"`
// Permissions is what the account may do. Empty means it can act only on its own
// records and what is shared with it.
Permissions []string `json:"permissions"`
}
ServiceAccountCreate is the payload for creating a service account.
func (*ServiceAccountCreate) Validate ¶
func (r *ServiceAccountCreate) Validate() []httpx.FieldError
Validate implements httpx.Validator.
type ServiceAccountResponse ¶
type ServiceAccountResponse struct {
ServiceAccountID string `json:"serviceAccountId"`
Name string `json:"name"`
DisplayName *string `json:"displayName"`
Description *string `json:"description"`
Email *string `json:"email"`
Status *model.UserStatus `json:"status"`
CreatedBy string `json:"createdBy"`
CreatedAt int64 `json:"createdAt"`
TokenIssuedAt int64 `json:"tokenIssuedAt"`
TokenExpiresAt int64 `json:"tokenExpiresAt"`
// Permissions is what the account is allowed to do, sorted.
Permissions []string `json:"permissions"`
}
ServiceAccountResponse is the read model for a service account. It never carries the token.
func ToServiceAccountResponse ¶
func ToServiceAccountResponse(u *model.User) ServiceAccountResponse
ToServiceAccountResponse maps a service account user, which must have its ServiceAccount row loaded.
type ServiceAccountTokenRequest ¶
type ServiceAccountTokenRequest struct {
// ValidityDays is how long the token lives from now. Defaults to 90.
ValidityDays *int `json:"validityDays"`
}
ServiceAccountTokenRequest is the payload for renewing or regenerating a token.
func (*ServiceAccountTokenRequest) Validate ¶
func (r *ServiceAccountTokenRequest) Validate() []httpx.FieldError
Validate implements httpx.Validator.
type ServiceAccountTokenResponse ¶
type ServiceAccountTokenResponse struct {
ServiceAccount ServiceAccountResponse `json:"serviceAccount"`
Token string `json:"token"`
}
ServiceAccountTokenResponse is returned when a token is minted: on create and on regenerate. It is the only time the token is ever sent.
type ServiceAccountUpdate ¶
type ServiceAccountUpdate struct {
DisplayName *string `json:"displayName"`
Description *string `json:"description"`
Email *string `json:"email"`
Status *model.UserStatus `json:"status"`
// Permissions, when present, replaces the account's whole set; an empty list
// removes every grant. Absent leaves the set as it is.
Permissions *[]string `json:"permissions"`
}
ServiceAccountUpdate changes an account's profile, status or permissions. Absent fields are left as they are.
func (*ServiceAccountUpdate) Validate ¶
func (r *ServiceAccountUpdate) Validate() []httpx.FieldError
Validate implements httpx.Validator.
type UserAccountResponse ¶
type UserAccountResponse struct {
UserID string `json:"userId"`
Status *model.UserStatus `json:"status"`
FirstName *string `json:"firstName"`
LastName *string `json:"lastName"`
Email *string `json:"email"`
AuthMethod *model.AuthMethod `json:"authMethod"`
Roles []model.Role `json:"roles"`
CreatedAt int64 `json:"createdAt"`
}
UserAccountResponse is the fuller read model administrators see when listing users, and users see for themselves: unlike UserResponse it carries the email, the auth method and the roles an administrator needs to decide whether to activate someone.
func ToUserAccountResponse ¶
func ToUserAccountResponse(u *model.User) UserAccountResponse
type UserAdminUpdate ¶
type UserAdminUpdate struct {
Admin bool `json:"admin"`
}
UserAdminUpdate grants or withdraws the ADMIN role.
type UserRegistration ¶
type UserRegistration struct {
UserID string `json:"userId"`
Email *string `json:"email"`
FirstName *string `json:"firstName"`
LastName *string `json:"lastName"`
AuthMethod *model.AuthMethod `json:"authMethod"`
}
UserRegistration is the create/update payload for a user.
Java: org.apache.airavata.iam.dto.UserRegistrationDto
func (*UserRegistration) Validate ¶
func (r *UserRegistration) Validate() []httpx.FieldError
Validate implements httpx.Validator.
type UserResponse ¶
type UserResponse struct {
UserID string `json:"userId"`
Status *model.UserStatus `json:"status"`
FirstName *string `json:"firstName"`
LastName *string `json:"lastName"`
CreatedAt int64 `json:"createdAt"`
}
UserResponse is the read model for a user.
It deliberately omits email, auth method and roles — the Java response DTO exposes only these five fields, and widening it here would leak more about an account than the API ever has.
Java: org.apache.airavata.iam.dto.UserResponseDto
func ToUserResponse ¶
func ToUserResponse(u *model.User) UserResponse
type UserStatusUpdate ¶
type UserStatusUpdate struct {
Status model.UserStatus `json:"status"`
}
UserStatusUpdate sets a user's status.
func (*UserStatusUpdate) Validate ¶
func (r *UserStatusUpdate) Validate() []httpx.FieldError
Validate implements httpx.Validator.