api

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ErrorStrInvalidRequest       = "invalid_request"
	ErrorStrInvalidClient        = "invalid_client"
	ErrorStrInvalidGrant         = "invalid_grant"
	ErrorStrUnauthorizedClient   = "unauthorized_client"
	ErrorStrUnsupportedGrantType = "unsupported_grant_type"
	ErrorStrInvalidScope         = "invalid_scope"
	ErrorStrInvalidToken         = "invalid_token"
	ErrorStrInsufficientScope    = "insufficient_scope"
	ErrorStrExpiredToken         = "expired_token"
	ErrorStrAccessDenied         = "access_denied"
	ErrorStrAuthorizationPending = "authorization_pending"
	ErrorStrMailRequired         = "mail_required"
)

Predefined OAuth2/OIDC errors

View Source
const (
	ErrorStrInternal                 = "internal_server_error"
	ErrorStrOIDC                     = "oidc_error"
	ErrorStrNYI                      = "not_yet_implemented"
	ErrorStrInsufficientCapabilities = "insufficient_capabilities"
	ErrorStrUsageRestricted          = "usage_restricted"
)

Additional Mytoken errors

View Source
const (
	ClientTypeWeb    = "web"
	ClientTypeNative = "native"
)

Client types

View Source
const (
	GrantTypeMytoken      = "mytoken"
	GrantTypeOIDCFlow     = "oidc_flow"
	GrantTypePollingCode  = "polling_code"
	GrantTypeTransferCode = "transfer_code"
	GrantTypeSSH          = "ssh"
)

GrantTypes

View Source
const (
	NotificationTypeMail      = "mail"
	NotificationTypeWebsocket = "ws"
	NotificationTypeICSInvite = "ics_invite"
)

Variables for different notification types

View Source
const (
	ResponseTypeToken        = "token"
	ResponseTypeShortToken   = "short_token"
	ResponseTypeTransferCode = "transfer_code"
)

ResponseTypes

View Source
const (
	RestrictionClaimNotBefore     = "nbf"
	RestrictionClaimExpiresAt     = "exp"
	RestrictionClaimScope         = "scope"
	RestrictionClaimAudiences     = "audience"
	RestrictionClaimHosts         = "hosts"
	RestrictionClaimGeoIPAllow    = "geoip_allow"
	RestrictionClaimGeoIPDisallow = "geoip_disallow"
	RestrictionClaimUsagesAT      = "usages_AT"
	RestrictionClaimUsagesOther   = "usages_other"
)

RestrictionClaims

View Source
const (
	SSHMimetypeJson       = "application/json"
	SSHMimetypeJsonBase64 = "application/json;base64"
)

ssh payload mimetypes

View Source
const (
	SSHRequestMytoken               = "MT"
	SSHRequestAccessToken           = "AT"
	SSHRequestTokenInfoIntrospect   = "introspect"
	SSHRequestTokenInfoHistory      = "history"
	SSHRequestTokenInfoSubtokens    = "list-subtokens"
	SSHRequestTokenInfoListMytokens = "list-all-mytokens"
)

ssh request types

View Source
const (
	TokeninfoActionIntrospect    = "introspect"
	TokeninfoActionEventHistory  = "event_history"
	TokeninfoActionSubtokens     = "subtokens"
	TokeninfoActionListMytokens  = "list_mytokens"
	TokeninfoActionNotifications = "notifications"
)

TokeninfoActions

View Source
const (
	MOMIDValueThis     = "this"
	MOMIDValueChildren = "children"
)
View Source
const CapabilityReadOnlyPrefix = "read@"
View Source
const MinShortTokenLen = 32

MinShortTokenLen is the minimum length of a short token

View Source
const (
	OIDCFlowAuthorizationCode = "authorization_code"
)

OIDCFlows

View Source
const TokenType = "mytoken"

TokenType is a constant that can be used for identifying mytokens and to distinguish them from OIDC tokens

Variables

View Source
var (
	ErrorUnknownIssuer = Error{
		ErrorStrInvalidRequest,
		"The provided issuer is not supported",
	}
	ErrorStateMismatch = Error{
		ErrorStrInvalidRequest,
		"State mismatched",
	}
	ErrorUnsupportedOIDCFlow = Error{
		ErrorStrInvalidGrant,
		"Unsupported oidc_flow",
	}
	ErrorUnsupportedGrantType = Error{
		ErrorStrInvalidGrant,
		"Unsupported grant_type",
	}
	ErrorBadTransferCode = Error{
		ErrorStrInvalidToken,
		"Bad polling or transfer code",
	}
	ErrorTransferCodeExpired = Error{
		ErrorStrExpiredToken,
		"polling or transfer code is expired",
	}
	ErrorAuthorizationPending = Error{
		ErrorStrAuthorizationPending,
		"",
	}
	ErrorConsentDeclined = Error{
		ErrorStrAccessDenied,
		"user declined consent",
	}
	ErrorNoRefreshToken = Error{
		ErrorStrOIDC,
		"Did not receive a refresh token",
	}
	ErrorInsufficientCapabilities = Error{
		ErrorStrInsufficientCapabilities,
		"The provided token does not have the required capability for this operation",
	}
	ErrorUsageRestricted = Error{
		ErrorStrUsageRestricted,
		"The restrictions of this token does not allow this usage",
	}
	ErrorMailRequired = Error{
		ErrorStrMailRequired,
		"to fulfill the request we need a valid email address; we currently do not have a email address associated" +
			" with the user",
	}
	ErrorMailNotVerified = Error{
		ErrorStrMailRequired,
		"email not verified",
	}
	ErrorNYI = Error{
		ErrorStrNYI,
		"",
	}
)

Predefined errors

View Source
var (
	CapabilityAT = Capability{
		Name:        "AT",
		Description: "Allows obtaining OpenID Connect Access Tokens.",
	}
	CapabilityCreateMT = Capability{
		Name:        "create_mytoken",
		Description: "Allows to create a new mytoken.",
	}
	CapabilitySettings = Capability{
		Name:        "settings",
		Description: "Allows read/write access to user settings.",
	}
	CapabilitySettingsRead = Capability{
		Name:        CapabilityReadOnlyPrefix + CapabilitySettings.Name,
		Description: "Allows read access to user settings.",
	}
	CapabilityGrants = Capability{
		Name:        CapabilitySettings.Name + ":grants",
		Description: "Allows read/write access to user grants.",
	}
	CapabilityGrantsRead = Capability{
		Name:        CapabilityReadOnlyPrefix + CapabilityGrants.Name,
		Description: "Allows read access to user grants.",
	}
	CapabilitySSHGrant = Capability{
		Name:        CapabilityGrants.Name + ":ssh",
		Description: "Allows read/write access to the ssh grant.",
	}
	CapabilitySSHGrantRead = Capability{
		Name:        CapabilityReadOnlyPrefix + CapabilitySSHGrant.Name,
		Description: "Allows read access to the ssh grant.",
	}
	CapabilityEmail = Capability{
		Name:        CapabilitySettings.Name + ":email",
		Description: "Allows read/write access to email settings.",
	}
	CapabilityEmailRead = Capability{
		Name:        CapabilityReadOnlyPrefix + CapabilityEmail.Name,
		Description: "Allows read access to email settings.",
	}
	CapabilityTags = Capability{
		Name:        CapabilitySettings.Name + ":tags",
		Description: "Allows read/write access to managing tags.",
	}
	CapabilityTagsRead = Capability{
		Name:        CapabilityReadOnlyPrefix + CapabilityTags.Name,
		Description: "Allows read access to tags.",
	}
	CapabilityTokeninfo = Capability{
		Name:        "tokeninfo",
		Description: "Allows to obtain all information about this token.",
	}
	CapabilityTokeninfoIntrospect = Capability{
		Name:        subcapabilityName(CapabilityTokeninfo, "introspect"),
		Description: "Allows to obtain basic information about this token.",
	}
	CapabilityTokeninfoHistory = Capability{
		Name:        subcapabilityName(CapabilityTokeninfo, "history"),
		Description: "Allows to obtain the event history for this token and all subtokens.",
	}
	CapabilityTokeninfoSubtokens = Capability{
		Name:        subcapabilityName(CapabilityTokeninfo, "subtokens"),
		Description: "Allows to list a subtoken-tree for this token.",
	}
	CapabilityTokeninfoNotify = Capability{
		Name:        subcapabilityName(CapabilityTokeninfo, "notify"),
		Description: "Allows to manage notifications for this mytoken.",
	}
	CapabilityTokeninfoTags = Capability{
		Name:        subcapabilityName(CapabilityTokeninfo, "tags"),
		Description: "Allows to manage tags for this mytoken.",
	}
	CapabilityManageMTs = Capability{
		Name:        "manage_mytokens",
		Description: "Allows to manage (obtain metadata and revoke) all mytoken.",
	}
	CapabilityListMT = Capability{
		Name:        subcapabilityName(CapabilityManageMTs, "list"),
		Description: "Allows to list metadata about all mytokens.",
	}
	CapabilityRevokeAnyToken = Capability{
		Name:        subcapabilityName(CapabilityManageMTs, "revoke"),
		Description: "Allows to revoke any mytoken.",
	}
	CapabilityHistoryAnyToken = Capability{
		Name:        subcapabilityName(CapabilityManageMTs, "history"),
		Description: "Allows to obtain the event history for any token.",
	}
	CapabilityNotifyAnyToken = Capability{
		Name:        subcapabilityName(CapabilityManageMTs, "notify"),
		Description: "Allows to manage notifications for any token.",
	}
	CapabilityTagAnyToken = Capability{
		Name:        subcapabilityName(CapabilityManageMTs, "tags"),
		Description: "Allows to manage tags for any token.",
	}
	CapabilityNotifyAnyTokenRead = Capability{
		Name:        CapabilityReadOnlyPrefix + CapabilityNotifyAnyToken.Name,
		Description: "Allows to read notifications for any token.",
	}
)

Defined Capabilities

View Source
var (
	EventUnknown                          = Event("unknown")
	EventMTCreated                        = Event("created")
	EventATCreated                        = Event("AT_created")
	EventSubtokenCreated                  = Event("MT_created")
	EventTokenInfoIntrospect              = Event("tokeninfo_introspect")
	EventTokenInfoHistory                 = Event("tokeninfo_history")
	EventTokenInfoSubtokens               = Event("tokeninfo_subtokens")
	EventTokenInfoListMTs                 = Event("tokeninfo_list_mytokens")
	EventTokenInfoNotifications           = Event("tokeninfo_notifications")
	EventInheritedRT                      = Event("inherited_RT")
	EventTransferCodeCreated              = Event("transfer_code_created")
	EventTransferCodeUsed                 = Event("transfer_code_used")
	EventMTRotated                        = Event("token_rotated")
	EventGrantEnabled                     = Event("settings_grant_enabled")
	EventGrantDisabled                    = Event("settings_grant_disabled")
	EventGrantsListed                     = Event("settings_grants_listed")
	EventSSHKeyListed                     = Event("ssh_keys_listed")
	EventSSHKeyAdded                      = Event("ssh_key_added")
	EventRevokedOtherToken                = Event("revoked_other_token")
	EventTokenInfoHistoryOtherToken       = Event("tokeninfo_history_other_token")
	EventTokenInfoNotificationsOtherToken = Event("tokeninfo_notifications_other_token")
	EventExpired                          = Event("expired")
	EventRevoked                          = Event("revoked")
	EventNotificationSubscribed           = Event("notification_subscribed")
	EventNotificationListed               = Event("notification_listed")
	EventNotificationUnsubscribed         = Event("notification_unsubscribed")
	EventNotificationSubscribedOther      = Event("notification_subscribed_other")
	EventNotificationUnsubscribedOther    = Event("notification_unsubscribed_other")
	EventNotificationCreated              = Event("notification_created")
	EventNotificationCreatedOther         = Event("notification_created_other")
	EventCalendarCreated                  = Event("calendar_created")
	EventCalendarUpdated                  = Event("calendar_updated")
	EventCalendarListed                   = Event("calendar_listed")
	EventCalendarDeleted                  = Event("calendar_deleted")
	EventEmailSettingsListed              = Event("email_settings_listed")
	EventEmailChanged                     = Event("email_changed")
	EventEmailMimetypeChanged             = Event("email_mimetype_changed")
	EventTagsListed                       = Event("tags_listed")
	EventTagCreated                       = Event("tag_created")
	EventTagDeleted                       = Event("tag_deleted")
	EventTagUpdated                       = Event("tag_updated")
	EventTagAddedToken                    = Event("tag_added_to_token")
	EventTagAddedTokenOther               = Event("tag_added_to_other_token")
	EventTagRemovedToken                  = Event("tag_removed_from_token")
	EventTagRemovedTokenOther             = Event("tag_removed_from_other_token")
	EventCalendarTagsUpdated              = Event("calendar_tags_updated")
	EventNotificationTagsUpdated          = Event("notification_tags_updated")
)

Events for Mytokens

View Source
var (
	NotificationClassATs = &NotificationClass{
		Name:           "AT_creations",
		Description:    "Notifications for the creation of access tokens",
		relevantEvents: []Event{EventATCreated},
	}
	NotificationClassMTs = &NotificationClass{
		Name:           "subtoken_creations",
		Description:    "Notifications for the creation of mytoken subtokens",
		relevantEvents: []Event{EventMTCreated},
	}
	NotificationClassSettingChanges = &NotificationClass{
		Name:        "setting_changes",
		Description: "Notifications for changes in the settings",
		relevantEvents: []Event{
			EventCalendarCreated,
			EventCalendarDeleted,
			EventEmailChanged,
			EventEmailMimetypeChanged,
			EventSSHKeyAdded,
			EventGrantEnabled,
			EventGrantDisabled,
		},
	}
	NotificationClassSecurity = &NotificationClass{
		Name:        "security",
		Description: "Notifications for all security related events",
	}
	NotificationClassBlockedUsages = &NotificationClass{
		Name:        subNotificationClassName(NotificationClassSecurity, "blocked_usages"),
		Description: "Notifications for blocked usages",
	}
	NotificationClassInsufficientCapabilities = &NotificationClass{
		Name:        subNotificationClassName(NotificationClassBlockedUsages, "capabilities"),
		Description: "Notifications for blocked usages because of insufficient capabilities",
	}
	NotificationClassRestrictedUsages = &NotificationClass{
		Name:        subNotificationClassName(NotificationClassBlockedUsages, "restrictions"),
		Description: "Notifications for blocked usages because of restrictions",
	}
	NotificationClassRevokedUsage = &NotificationClass{
		Name:        subNotificationClassName(NotificationClassSecurity, "revoked"),
		Description: "Notifications for tried usage of a revoked token (only works as a user-wide notification)",
	}
	NotificationClassUnusualIPs = &NotificationClass{
		Name:        subNotificationClassName(NotificationClassSecurity, "ips"),
		Description: "Notifications for usages from previously unknown ip addresses",
	}
	NotificationClassExpiration = &NotificationClass{
		Name:        "expiration",
		Description: "Notifications before a mytoken expires",
	}
	NotificationClassRTFailure = &NotificationClass{
		Name:        "rt_failure",
		Description: "Notifications when a refresh token could not be used",
	}
)

Defined NotificationClasses

AllCapabilities holds all defined Capabilities

AllGrantTypes holds all the GrantTypes

AllNotificationClasses holds all defined NotificationClasses

AllRestrictionClaims holds all the RestrictionClaims

AllTokeninfoActions holds all defined TokenInfo strings

View Source
var DefaultCapabilities = Capabilities{
	CapabilityAT,
	CapabilityTokeninfo,
}

DefaultCapabilities holds the default Capabilities

View Source
var TokenVer = TokenVersion{
	Major: 0,
	Minor: 7,
}

TokenVer is the current Mytoken TokenVersion

Functions

This section is empty.

Types

type AccessTokenRequest

type AccessTokenRequest struct {
	Issuer    string `json:"oidc_issuer,omitempty" form:"issuer" xml:"oidc_issuer"`
	GrantType string `json:"grant_type" form:"grant_type" xml:"grant_type"`
	Mytoken   string `json:"mytoken" form:"mytoken" xml:"mytoken"`
	Scope     string `json:"scope,omitempty" form:"scope" xml:"scope"`
	Audience  string `json:"audience,omitempty" form:"audience" xml:"audience"`
	Comment   string `json:"comment,omitempty" form:"comment" xml:"comment"`
}

AccessTokenRequest holds an request for an access token

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken string           `json:"access_token"`
	TokenType   string           `json:"token_type"`
	ExpiresIn   int64            `json:"expires_in"`
	Scope       string           `json:"scope,omitempty"`
	Audiences   []string         `json:"audience,omitempty"`
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

AccessTokenResponse is the response to a access token request

type AddMytokenToCalendarRequest added in v0.12.0

type AddMytokenToCalendarRequest struct {
	MomID   string `json:"mom_id" xml:"mom_id" form:"mom_id"`
	Comment string `json:"comment" xml:"comment" form:"comment"`
}

type AddTagToMytokenRequest added in v0.12.0

type AddTagToMytokenRequest struct {
	Tag             Tag    `json:"tag"`
	Mytoken         string `json:"mytoken,omitempty" form:"mytoken" xml:"mytoken"`
	MOMID           string `json:"mom_id,omitempty" form:"mom_id" xml:"mom_id"`
	IncludeChildren bool   `json:"include_children" form:"include_children" xml:"include_children"`
}

type AuthCodeFlowRequest

type AuthCodeFlowRequest struct {
	OIDCFlowRequest
	ClientType  string `json:"client_type"`
	RedirectURI string `json:"redirect_uri"`
}

AuthCodeFlowRequest holds a authorization code flow request

type AuthCodeFlowResponse

type AuthCodeFlowResponse struct {
	ConsentURI string `json:"consent_uri"`
	PollingInfo
}

AuthCodeFlowResponse is the response to an authorization code flow request

type CalendarInfo added in v0.12.0

type CalendarInfo struct {
	NotificationCalendar
	SubscribedTokens []string `json:"subscribed_tokens,omitempty"`
}

type CalendarListResponse added in v0.12.0

type CalendarListResponse struct {
	Calendars   []CalendarInfo   `json:"calendars"`
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

CalendarListResponse is the response returned to list all calendars of a user

type Capabilities

type Capabilities []Capability

Capabilities is a slice of Capability

func NewCapabilities

func NewCapabilities(caps []string) (c Capabilities)

NewCapabilities casts a []string into Capabilities

func TightenCapabilities

func TightenCapabilities(a, b Capabilities) (res Capabilities)

TightenCapabilities tightens two set of Capabilities into one new

func (Capabilities) Has

func (c Capabilities) Has(a Capability) bool

Has checks if Capabilities slice contains the passed Capability

func (*Capabilities) Scan

func (c *Capabilities) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Capabilities) Strings

func (c Capabilities) Strings() (s []string)

Strings returns a slice of strings for these capabilities

func (Capabilities) Value

func (c Capabilities) Value() (driver.Value, error)

Value implements the driver.Valuer interface

type Capability

type Capability struct {
	Name        string
	Description string
}

Capability is a capability string

func NewCapability

func NewCapability(name string) Capability

NewCapability casts a string into a Capability

func (Capability) MarshalJSON

func (c Capability) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*Capability) UnmarshalJSON

func (c *Capability) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type ClientMetaData

type ClientMetaData struct {
	IP        string `db:"ip" json:"ip,omitempty"`
	UserAgent string `db:"user_agent" json:"user_agent,omitempty"`
}

ClientMetaData hold information about the calling client

type CreateCalendarRequest added in v0.12.0

type CreateCalendarRequest struct {
	Description string `json:"description,omitempty"`
	Tags        []Tag  `json:"tags"`
}

type CreateMytokenSubscribeNotificationInfos added in v0.12.0

type CreateMytokenSubscribeNotificationInfos struct {
	IncludeChildren     bool                `json:"include_children" xml:"include_children" form:"include_children"`
	NotificationType    string              `json:"notification_type" xml:"notification_type" form:"notification_type"`
	NotificationClasses NotificationClasses `json:"notification_classes" xml:"notification_classes" form:"notification_classes"`
}

type CreateMytokenTag added in v0.12.0

type CreateMytokenTag struct {
	Tag             Tag  `json:"tag"`
	IncludeChildren bool `json:"include_children,omitempty"`
}

CreateMytokenTag is used when specifying tags during mytoken creation

type CreateTransferCodeRequest

type CreateTransferCodeRequest struct {
	Mytoken string `json:"mytoken"`
}

CreateTransferCodeRequest is a request to create a new transfer code from an existing mytoken

type Error

type Error struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description,omitempty"`
}

Error is an error object that is returned on the api when an error occurs

func (Error) CombinedMessage

func (e Error) CombinedMessage() string

CombinedMessage returns an error string that combines the error with the error description

type Event added in v0.12.0

type Event string

Event is a type for events

func NewEvent added in v0.12.0

func NewEvent(typ string) Event

NewEvent creates a new Event from the event string

func (*Event) Scan added in v0.12.0

func (e *Event) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (Event) String added in v0.12.0

func (e Event) String() string

func (Event) Value added in v0.12.0

func (e Event) Value() (driver.Value, error)

Value implements the sql.Valuer interface

type EventEntry

type EventEntry struct {
	Event          Event  `db:"event" json:"event"`
	Time           int64  `db:"time" json:"time"`
	Comment        string `db:"comment" json:"comment,omitempty"`
	ClientMetaData `json:",inline"`
	MOMID          string `json:"mom_id,omitempty"`
}

EventEntry is a type holding information about an event

type EventHistory

type EventHistory struct {
	Events []EventEntry `json:"events"`
}

EventHistory is a slice of EventEntry

type ExchangeTransferCodeRequest

type ExchangeTransferCodeRequest struct {
	GrantType    string `json:"grant_type"`
	TransferCode string `json:"transfer_code"`
}

ExchangeTransferCodeRequest is a request to exchange a transfer code for the mytoken

type GeneralMytokenRequest

type GeneralMytokenRequest struct {
	Issuer                        string                                    `json:"oidc_issuer,omitempty"`
	GrantType                     string                                    `json:"grant_type,omitempty"`
	Restrictions                  Restrictions                              `json:"restrictions,omitempty"`
	Capabilities                  Capabilities                              `json:"capabilities,omitempty"`
	Name                          string                                    `json:"name,omitempty"`
	ResponseType                  string                                    `json:"response_type,omitempty"`
	MaxTokenLen                   int                                       `json:"max_token_len,omitempty"`
	Rotation                      *Rotation                                 `json:"rotation,omitempty"`
	ApplicationName               string                                    `json:"application_name,omitempty"`
	IncludedProfiles              IncludedProfiles                          `json:"include,omitempty"`
	SubscribeNotificationRequests []CreateMytokenSubscribeNotificationInfos `json:"subscribe_notifications,omitempty"`
	Tags                          []CreateMytokenTag                        `json:"tags,omitempty"`
}

GeneralMytokenRequest is a type that holds all the information that all mytoken requests have in common. It should not be used directly as a request object

type GrantTypeInfo

type GrantTypeInfo struct {
	GrantType string `json:"grant_type"`
	Enabled   bool   `json:"enabled"`
}

GrantTypeInfo is a struct holding information indicating if a grant type is enabled or not

type GrantTypeInfoResponse

type GrantTypeInfoResponse struct {
	GrantTypes  []GrantTypeInfo  `json:"grant_types"`
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

type GrantTypeRequest

type GrantTypeRequest struct {
	GrantType string `json:"grant_type" form:"grant_type" xml:"grant_type"`
	Mytoken   string `json:"mytoken" form:"mytoken" xml:"mytoken"`
}

GrantTypeRequest is a request object for grant type requests at the grant type settings endpoint. The same GrantTypeRequest struct is used for Enable and Disable requests

type IncludedProfiles added in v0.10.0

type IncludedProfiles []string

func NewIncludedProfiles added in v0.10.0

func NewIncludedProfiles(profiles ...string) IncludedProfiles

NewIncludedProfiles creates a new IncludedProfiles var from the past profile names

func (IncludedProfiles) MarshalJSON added in v0.10.0

func (i IncludedProfiles) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*IncludedProfiles) UnmarshalJSON added in v0.10.0

func (i *IncludedProfiles) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type MTTagInfo added in v0.12.0

type MTTagInfo struct {
	TagInfo
	IncludeChildren bool `json:"include_children"`
}

type MailSettingsInfoResponse added in v0.12.0

type MailSettingsInfoResponse struct {
	EmailAddress   string           `json:"email_address"`
	EmailVerified  bool             `json:"email_verified"`
	PreferHTMLMail bool             `json:"prefer_html_mail"`
	TokenUpdate    *MytokenResponse `json:"token_update,omitempty"`
}

type ManagementCodeNotificationInfoResponse added in v0.12.0

type ManagementCodeNotificationInfoResponse struct {
	NotificationInfo
	OIDCIssuer string `json:"oidc_iss"`
	OIDCSub    string `json:"oidc_sub"`
}

ManagementCodeNotificationInfoResponse is the response to a request to obtain infos about a notification via a management code This response will contain the oidc issuer url and subject, this allows the client to map the notification to an issuer and also to obtain a mytoken for the correct issuer in order to obtain additional information. The oidc_sub is included to allow the client to detect if the logged-in user is the owner of the notification.

type Mytoken

type Mytoken struct {
	Version      TokenVersion `json:"ver"`
	TokenType    string       `json:"token_type"`
	Issuer       string       `json:"iss"`
	Subject      string       `json:"sub"`
	ExpiresAt    int64        `json:"exp,omitempty"`
	NotBefore    int64        `json:"nbf"`
	IssuedAt     int64        `json:"iat"`
	AuthTime     int64        `json:"auth_time"`
	ID           string       `json:"jti"`
	SeqNo        uint64       `json:"seq_no"`
	Name         string       `json:"name,omitempty"`
	Audience     string       `json:"aud"`
	OIDCSubject  string       `json:"oidc_sub"`
	OIDCIssuer   string       `json:"oidc_iss"`
	Restrictions Restrictions `json:"restrictions,omitempty"`
	Capabilities Capabilities `json:"capabilities"`
	Rotation     *Rotation    `json:"rotation,omitempty"`
}

Mytoken is a mytoken Mytoken

type MytokenConfiguration

type MytokenConfiguration struct {
	Issuer                                 string                    `json:"issuer"`
	AccessTokenEndpoint                    string                    `json:"access_token_endpoint"`
	MytokenEndpoint                        string                    `json:"mytoken_endpoint"`
	TokeninfoEndpoint                      string                    `json:"tokeninfo_endpoint,omitempty"`
	RevocationEndpoint                     string                    `json:"revocation_endpoint,omitempty"`
	UserSettingsEndpoint                   string                    `json:"usersettings_endpoint"`
	NotificationsEndpoint                  string                    `json:"notifications_endpoint,omitempty"`
	TokenTransferEndpoint                  string                    `json:"token_transfer_endpoint,omitempty"`
	ProfilesEndpoint                       string                    `json:"profiles_endpoint,omitempty"`
	JWKSURI                                string                    `json:"jwks_uri"`
	SSHKeys                                []SSHKeyMetadata          `json:"ssh_keys,omitempty"`
	ProvidersSupported                     []SupportedProviderConfig `json:"providers_supported"`
	TokenSigningAlgValue                   string                    `json:"token_signing_alg_value"`
	TokenInfoEndpointActionsSupported      []string                  `json:"tokeninfo_endpoint_actions_supported,omitempty"`
	AccessTokenEndpointGrantTypesSupported []string                  `json:"access_token_endpoint_grant_types_supported"`
	MytokenEndpointGrantTypesSupported     []string                  `json:"mytoken_endpoint_grant_types_supported"`
	MytokenEndpointOIDCFlowsSupported      []string                  `json:"mytoken_endpoint_oidc_flows_supported"`
	ResponseTypesSupported                 []string                  `json:"response_types_supported"`
	ServiceDocumentation                   string                    `json:"service_documentation,omitempty"`
	RestrictionClaimsSupported             []string                  `json:"restriction_claims_supported"`
	Version                                string                    `json:"version,omitempty"`
}

MytokenConfiguration holds information about a mytoken instance

type MytokenEntry

type MytokenEntry struct {
	// The "Manage-Other-Mytokens-ID (MOMID) is used in requests to manage other mytokens than the one used for
	// authorization
	MOMID          string      `json:"mom_id"`
	Name           string      `json:"name,omitempty"`
	CreatedAt      int64       `json:"created"`
	ExpiresAt      int64       `json:"expires_at,omitempty"`
	Tags           []MTTagInfo `json:"tags,omitempty"`
	ClientMetaData `json:",inline"`
}

MytokenEntry holds the information of a MytokenEntry as stored in the database

type MytokenEntryTree

type MytokenEntryTree struct {
	Token    MytokenEntry       `json:"token"`
	Children []MytokenEntryTree `json:"children,omitempty"`
}

MytokenEntryTree is a tree of MytokenEntry

type MytokenFromMytokenRequest

type MytokenFromMytokenRequest struct {
	GeneralMytokenRequest
	Mytoken                      string `json:"mytoken"`
	FailOnRestrictionsNotTighter bool   `json:"error_on_restrictions,omitempty"`
}

MytokenFromMytokenRequest is a request to create a new Mytoken from an existing Mytoken

type MytokenResponse

type MytokenResponse struct {
	Mytoken      string           `json:"mytoken,omitempty"`
	MytokenType  string           `json:"mytoken_type"`
	TransferCode string           `json:"transfer_code,omitempty"`
	MOMID        string           `json:"mom_id,omitempty"`
	ExpiresIn    uint64           `json:"expires_in,omitempty"`
	Restrictions Restrictions     `json:"restrictions,omitempty"`
	Capabilities Capabilities     `json:"capabilities,omitempty"`
	Rotation     *Rotation        `json:"rotation,omitempty"`
	TokenUpdate  *MytokenResponse `json:"token_update,omitempty"`
}

MytokenResponse is a response to a mytoken request

type NotificationAddTokenRequest added in v0.12.0

type NotificationAddTokenRequest struct {
	Mytoken         string `json:"mytoken,omitempty" form:"mytoken" xml:"mytoken"`
	MOMID           string `json:"mom_id,omitempty" form:"mom_id" xml:"mom_id"`
	IncludeChildren bool   `json:"include_children" form:"include_children" xml:"include_children"`
}

NotificationAddTokenRequest is a type holding a request to add a token a notification

type NotificationCalendar added in v0.12.0

type NotificationCalendar struct {
	ID          string    `json:"id"`
	ICSPath     string    `json:"ics_path"`
	Description string    `json:"description,omitempty"`
	Tags        []TagInfo `json:"tags"`
}

type NotificationClass added in v0.12.0

type NotificationClass struct {
	Name        string
	Description string
	// contains filtered or unexported fields
}

NotificationClass is a type for notification classes

func NewNotificationClass added in v0.12.0

func NewNotificationClass(name string) *NotificationClass

NewNotificationClass casts a string into a NotificationClass

func NotificationClassFromEvent added in v0.12.0

func NotificationClassFromEvent(event Event) *NotificationClass

NotificationClassFromEvent returns the *NotificationClass linked to an Event

func (NotificationClass) Contains added in v0.12.0

func (nc NotificationClass) Contains(v *NotificationClass) bool

Contains checks if the NotificationClass contains another NotificationClass (i.e. as a subclass)

func (*NotificationClass) GetChildren added in v0.12.0

func (nc *NotificationClass) GetChildren() NotificationClasses

GetChildren returns the children of a NotificationClass

func (NotificationClass) MarshalJSON added in v0.12.0

func (nc NotificationClass) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*NotificationClass) UnmarshalJSON added in v0.12.0

func (nc *NotificationClass) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type NotificationClasses added in v0.12.0

type NotificationClasses []*NotificationClass

func (NotificationClasses) Contains added in v0.12.0

func (classes NotificationClasses) Contains(v *NotificationClass) bool

Contains checks if the NotificationClasses contains a NotificationClass (also as a subclass)

func (NotificationClasses) Equals added in v0.12.0

func (classes NotificationClasses) Equals(other NotificationClasses) bool

type NotificationInfo added in v0.12.0

type NotificationInfo struct {
	NotificationInfoBase
	Classes          NotificationClasses `json:"notification_classes"`
	SubscribedTokens []string            `json:"subscribed_tokens,omitempty"`
	Tags             []TagInfo           `json:"tags,omitempty"`
}

NotificationInfo is a type for holding information about a notification including the subscribed NotificationClasses and tokens

type NotificationInfoBase added in v0.12.0

type NotificationInfoBase struct {
	NotificationID uint64 `db:"id" json:"notification_id"`
	Type           string `db:"type" json:"notification_type"`
	ManagementCode string `db:"management_code" json:"management_code"`
	WebSocketPath  string `db:"ws" json:"ws,omitempty"`
	UserWide       bool   `db:"user_wide" json:"user_wide"`
}

NotificationInfoBase is a type for holding the base information about a notification

type NotificationRemoveTokenRequest added in v0.12.0

type NotificationRemoveTokenRequest struct {
	Mytoken string `json:"mytoken,omitempty" form:"mytoken" xml:"mytoken"`
	MOMID   string `json:"mom_id,omitempty" form:"mom_id" xml:"mom_id"`
}

NotificationRemoveTokenRequest is a type holding a request to remove a token from a notification

type NotificationUpdateNotificationClassesRequest added in v0.12.0

type NotificationUpdateNotificationClassesRequest struct {
	Classes NotificationClasses `json:"notification_classes"`
}

NotificationUpdateNotificationClassesRequest is a type holding a request to update the notification classes of a notification Deprecated: Use NotificationUpdateRequest instead

type NotificationUpdateRequest added in v0.12.0

type NotificationUpdateRequest struct {
	Classes *NotificationClasses `json:"notification_classes,omitempty"`
	Tags    *[]Tag               `json:"tags,omitempty"`
}

NotificationUpdateRequest is a type holding a request to update a notification's classes and/or tags

type NotificationsCombinedResponse added in v0.12.0

type NotificationsCombinedResponse struct {
	Notifications []NotificationInfo `json:"notifications,omitempty"`
	Calendars     []CalendarInfo     `json:"calendars,omitempty"`
	TokenUpdate   *MytokenResponse   `json:"token_update,omitempty"`
}

NotificationsCombinedResponse is a type holding a response including information about notifications and calendars

type NotificationsCreateResponse added in v0.12.0

type NotificationsCreateResponse struct {
	ManagementCode string           `json:"management_code"`
	TokenUpdate    *MytokenResponse `json:"token_update,omitempty"`
}

NotificationsCreateResponse is a type holding the response returned after a new notification was created

type NotificationsListResponse added in v0.12.0

type NotificationsListResponse struct {
	Notifications []NotificationInfo `json:"notifications"`
	TokenUpdate   *MytokenResponse   `json:"token_update,omitempty"`
}

NotificationsListResponse is a type holding the response to a notification list request

type OIDCFlowRequest

type OIDCFlowRequest struct {
	GeneralMytokenRequest
	OIDCFlow string `json:"oidc_flow"`
}

OIDCFlowRequest holds the request for an OIDC Flow request

type OnlyTokenUpdateResponse

type OnlyTokenUpdateResponse struct {
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

OnlyTokenUpdateResponse is a type for responses that do not contain any content except for a ( possibly) updated mytoken

type PollingCodeRequest

type PollingCodeRequest struct {
	GrantType   string `json:"grant_type"`
	PollingCode string `json:"polling_code"`
}

PollingCodeRequest is a polling code request

type PollingInfo

type PollingInfo struct {
	PollingCode          string `json:"polling_code,omitempty"`
	PollingCodeExpiresIn int64  `json:"expires_in,omitempty"`
	PollingInterval      int64  `json:"interval,omitempty"`
}

PollingInfo holds all response information about polling codes

type Profile added in v0.10.0

type Profile struct {
	ID      string          `json:"id"`
	Name    string          `json:"name"`
	Payload json.RawMessage `json:"payload"`
}

type RemoveTagFromMytokenRequest added in v0.12.0

type RemoveTagFromMytokenRequest struct {
	Tag             Tag    `json:"tag"`
	Mytoken         string `json:"mytoken,omitempty" form:"mytoken" xml:"mytoken"`
	MOMID           string `json:"mom_id,omitempty" form:"mom_id" xml:"mom_id"`
	IncludeChildren bool   `json:"include_children" form:"include_children" xml:"include_children"`
}

type Restriction

type Restriction struct {
	NotBefore        int64            `json:"nbf,omitempty"`
	ExpiresAt        int64            `json:"exp,omitempty"`
	Scope            string           `json:"scope,omitempty"`
	Audiences        []string         `json:"audience,omitempty"`
	Hosts            []string         `json:"hosts,omitempty"`
	GeoIPAllow       []string         `json:"geoip_allow,omitempty"`
	GeoIPDisallow    []string         `json:"geoip_disallow,omitempty"`
	UsagesAT         *int64           `json:"usages_AT,omitempty"`
	UsagesOther      *int64           `json:"usages_other,omitempty"`
	IncludedProfiles IncludedProfiles `json:"include,omitempty"`
}

Restriction describes a token usage restriction

type Restrictions

type Restrictions []*Restriction

Restrictions is a slice of Restriction

type RevocationRequest

type RevocationRequest struct {
	Token      string `json:"token"`
	MOMID      string `json:"mom_id,omitempty"`
	Recursive  bool   `json:"recursive,omitempty"`
	OIDCIssuer string `json:"oidc_issuer,omitempty"`
}

RevocationRequest holds the information for a token revocation request

type Rotation

type Rotation struct {
	OnAT             bool             `json:"on_AT,omitempty"`
	OnOther          bool             `json:"on_other,omitempty"`
	Lifetime         uint64           `json:"lifetime,omitempty"`
	AutoRevoke       bool             `json:"auto_revoke,omitempty"`
	IncludedProfiles IncludedProfiles `json:"include,omitempty"`
}

Rotation is a type describing how a mytoken might be rotated

func (*Rotation) Scan

func (r *Rotation) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Rotation) Value

func (r Rotation) Value() (driver.Value, error)

Value implements the driver.Valuer interface

type SSHInfoResponse

type SSHInfoResponse struct {
	GrantEnabled bool             `json:"grant_enabled"`
	SSHKeyInfo   []SSHKeyInfo     `json:"ssh_keys"`
	TokenUpdate  *MytokenResponse `json:"token_update,omitempty"`
}

type SSHKeyAddFinalResponse

type SSHKeyAddFinalResponse struct {
	SSHUser       string `json:"ssh_user"`
	SSHHostConfig string `json:"ssh_host_config,omitempty"`
}

SSHKeyAddFinalResponse is a type for the final response for an SSHKeyAddRequest after the polling was successful

type SSHKeyAddRequest

type SSHKeyAddRequest struct {
	Mytoken      string       `json:"mytoken" form:"mytoken" xml:"mytoken"`
	SSHKey       string       `json:"ssh_key" form:"ssh_key" xml:"ssh_key"`
	Name         string       `json:"name" form:"name" xml:"name"`
	Restrictions Restrictions `json:"restrictions" form:"restrictions" xml:"restrictions"`
	Capabilities Capabilities `json:"capabilities" form:"capabilities" xml:"capabilities"`
	GrantType    string       `json:"grant_type" form:"grant_type" xml:"grant_type"`
}

type SSHKeyAddResponse

type SSHKeyAddResponse struct {
	AuthCodeFlowResponse
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

SSHKeyAddResponse is a type for the (first) response to an SSHKeyAddRequest

type SSHKeyDeleteRequest

type SSHKeyDeleteRequest struct {
	Mytoken           string `json:"mytoken" form:"mytoken" xml:"mytoken"`
	SSHKey            string `json:"ssh_key" form:"ssh_key" xml:"ssh_key"`
	SSHKeyFingerprint string `json:"ssh_key_fp" form:"ssh_key_fp" xml:"ssh_key_fp"`
}

type SSHKeyInfo

type SSHKeyInfo struct {
	Name              string `json:"name,omitempty"`
	SSHKey            string `json:"ssh_key,omitempty"`    // One of SSHKey and SSHKeyFingerprint MUST be given
	SSHKeyFingerprint string `json:"ssh_key_fp,omitempty"` // One of SSHKey and SSHKeyFingerprint MUST be given
	Created           int64  `json:"created"`
	LastUsed          *int64 `json:"last_used,omitempty"`
}

type SSHKeyMetadata

type SSHKeyMetadata struct {
	Type        string `json:"type"`
	Fingerprint string `json:"fingerprint"`
}

SSHKeyMetadata holds information about an ssh key

type SettingsMetaData

type SettingsMetaData struct {
	GrantTypeEndpoint string `json:"grant_type_endpoint,omitempty"`
	EmailEndpoint     string `json:"email_endpoint,omitempty"`
	TagsEndpoint      string `json:"tags_endpoint,omitempty"`
}

SettingsMetaData is the metadata related to settings

type SubscribeNotificationRequest added in v0.12.0

type SubscribeNotificationRequest struct {
	Mytoken             string              `json:"mytoken,omitempty" form:"mytoken" xml:"mytoken"`
	MOMID               string              `json:"mom_id,omitempty" form:"mom_id" xml:"mom_id"`
	NotificationType    string              `json:"notification_type" form:"notification_type" xml:"notification_type"`
	NotificationClasses NotificationClasses `json:"notification_classes" form:"notification_classes" xml:"notification_classes"`
	IncludeChildren     bool                `json:"include_children"`
	UserWide            bool                `json:"user_wide"`
	Comment             string              `json:"comment,omitempty" form:"comment" xml:"comment"` // only for notification_type=ics_invite
	Tags                []Tag               `json:"tags,omitempty"`
}

SubscribeNotificationRequest is a type holding a request to subscribe / create a new notification

type SupportedProviderConfig

type SupportedProviderConfig struct {
	Issuer          string   `json:"issuer"`
	Name            string   `json:"name,omitempty"`
	ScopesSupported []string `json:"scopes_supported"`
	OIDFed          bool     `json:"oidfed,omitempty"`
}

SupportedProviderConfig holds information about a provider

type Tag added in v0.12.0

type Tag string

Tag is a type representing a tag name

type TagInfo added in v0.12.0

type TagInfo struct {
	Tag   Tag    `json:"tag" db:"tag"`
	Color string `json:"color" db:"color"`
}

TagInfo provides information about a tag

type TagListingResponse added in v0.12.0

type TagListingResponse struct {
	Tags        []TagInfo        `json:"tags"`
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

TagListingResponse is the response type that lists tags of a user

type TokenInfoRequest

type TokenInfoRequest struct {
	Action  string   `json:"action"`
	Mytoken string   `json:"mytoken"`
	MOMIDs  []string `json:"mom_ids,omitempty"`
}

TokenInfoRequest is a type for requests to the tokeninfo endpoint

type TokenVersion

type TokenVersion struct {
	Major int
	Minor int
}

TokenVersion is a type for the mytoken version

func (TokenVersion) AtLeast added in v0.12.0

func (v TokenVersion) AtLeast(required TokenVersion) bool

func (TokenVersion) Before added in v0.12.0

func (v TokenVersion) Before(before TokenVersion) bool

func (TokenVersion) MarshalJSON

func (v TokenVersion) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (TokenVersion) String

func (v TokenVersion) String() string

String returns a version string

func (*TokenVersion) UnmarshalJSON

func (v *TokenVersion) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (TokenVersion) Version

func (v TokenVersion) Version() string

Version returns a version string

type TokeninfoHistoryResponse

type TokeninfoHistoryResponse struct {
	EventHistory
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

TokeninfoHistoryResponse is a type for the response for a history request

type TokeninfoIntrospectResponse

type TokeninfoIntrospectResponse struct {
	Valid     bool        `json:"valid"`
	TokenType string      `json:"token_type"`
	Token     UsedMytoken `json:"token"`
	MOMID     string      `json:"mom_id"`
}

TokeninfoIntrospectResponse is a type for the response for an introspect request

type TokeninfoListResponse

type TokeninfoListResponse struct {
	Tokens      []MytokenEntryTree `json:"mytokens"`
	TokenUpdate *MytokenResponse   `json:"token_update,omitempty"`
}

TokeninfoListResponse is a type for the response for a list request

type TokeninfoNotificationsResponse added in v0.12.0

type TokeninfoNotificationsResponse struct {
	NotificationsCombinedResponse
	MomIDMapping map[string]NotificationsCombinedResponse `json:"mom_id_mapping,omitempty"`
	TokenUpdate  *MytokenResponse                         `json:"token_update,omitempty"`
}

TokeninfoNotificationsResponse is a type for the response for a notifications request

type TokeninfoSubtokensResponse

type TokeninfoSubtokensResponse struct {
	Tokens      MytokenEntryTree `json:"mytokens"`
	TokenUpdate *MytokenResponse `json:"token_update,omitempty"`
}

TokeninfoSubtokensResponse is a type for the response for a tree request

type TransferCodeResponse

type TransferCodeResponse struct {
	MytokenType  string `json:"mytoken_type"`
	TransferCode string `json:"transfer_code"`
	ExpiresIn    uint64 `json:"expires_in"`
}

TransferCodeResponse is the response to a transfer code request

type UpdateMailSettingsRequest added in v0.12.0

type UpdateMailSettingsRequest struct {
	EmailAddress   string `json:"email_address,omitempty"`
	PreferHTMLMail *bool  `json:"prefer_html_mail,omitempty"`
}

type UsedMytoken

type UsedMytoken struct {
	Mytoken      `json:",inline"`
	Restrictions []UsedRestriction `json:"restrictions,omitempty"`
}

UsedMytoken is a type for a Mytoken that has been used, it additionally has information how often it has been used

type UsedRestriction

type UsedRestriction struct {
	Restriction     `json:",inline"`
	UsagesATDone    *int64 `json:"usages_AT_done,omitempty"`
	UsagesOtherDone *int64 `json:"usages_other_done,omitempty"`
}

UsedRestriction is a type for a restriction that has been used and additionally has information how often it has been used

Jump to

Keyboard shortcuts

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