mytokenlib

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 9 Imported by: 2

README

mytoken logo

License GitHub go.mod Go version Go Report DeepSource Release date Release version

mytokenlib

mytokenlib is a go library for communicating with a mytoken server. mytoken is a central web service with the goal to easily obtain OpenID Connect access tokens across devices.

A mytoken command line client can be found at https://github.com/oidc-mytoken/client.

The mytoken server can be found at https://github.com/oidc-mytoken/server.

A demo instance of mytoken is running at https://mytoken.data.kit.edu/.

Documentation

Index

Constants

View Source
const ContextKeyUserAgent = "mytokenlib-user-agent"

ContextKeyUserAgent is used to set a useragent string in the context

Variables

This section is empty.

Functions

func NewAccessTokenRequest

func NewAccessTokenRequest(issuer, mytoken string, scopes, audiences []string, comment string) api.AccessTokenRequest

NewAccessTokenRequest creates a new api.AccessTokenRequest with the passed arguments

func SetClient added in v0.3.0

func SetClient(client *http.Client)

SetClient sets the http.Client used to make API requests

func SetContext added in v0.3.0

func SetContext(contxt context.Context)

SetContext sets a context.Context used for all API requests

Types

type AccessTokenEndpoint added in v0.3.0

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

AccessTokenEndpoint is type representing a mytoken server's Access Token Endpoint and the actions that can be performed there.

func (AccessTokenEndpoint) APIGet added in v0.3.0

func (at AccessTokenEndpoint) APIGet(
	mytoken string, oidcIssuer string, scopes, audiences []string, comment string,
) (resp api.AccessTokenResponse, err error)

APIGet uses the passed mytoken to return an access token with the specified attributes. If a non-empty string is passed as the oidcIssuer it must match the oidc issuer of the mytoken. If scopes and audiences are passed the access token is requested with these parameters, if omitted the default values for this mytoken / provider are used. Multiple scopes are passed as a space separated string. The comment details how the access token is intended to be used. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.AccessTokenResponse

func (AccessTokenEndpoint) DoHTTPRequest added in v0.3.0

func (at AccessTokenEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the access token endpoint

func (AccessTokenEndpoint) Get added in v0.3.0

func (at AccessTokenEndpoint) Get(
	mytoken *string, oidcIssuer string, scopes, audiences []string, comment string,
) (string, error)

Get uses the passed mytoken to return an access token with the specified attributes. If a non-empty string is passed as the oidcIssuer it must match the oidc issuer of the mytoken. If scopes and audiences are passed the access token is requested with these parameters, if omitted the default values for this mytoken / provider are used. Multiple scopes are passed as a space separated string. The comment details how the access token is intended to be used. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

type CalendarsEndpoint added in v0.8.0

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

CalendarsEndpoint is type representing a mytoken server's Calendars Endpoint

func (CalendarsEndpoint) APICreate added in v0.8.0

func (c CalendarsEndpoint) APICreate(mytoken string, req api.CreateCalendarRequest) (resp api.CalendarInfo, err error)

APICreate creates a new calendar

func (CalendarsEndpoint) APIDelete added in v0.8.0

func (c CalendarsEndpoint) APIDelete(mytoken, calendarID string) (resp api.OnlyTokenUpdateResponse, err error)

APIDelete deletes a calendar by ID

func (CalendarsEndpoint) APIList added in v0.8.0

func (c CalendarsEndpoint) APIList(mytoken string) (resp api.CalendarListResponse, err error)

APIList lists all calendars

func (CalendarsEndpoint) APISubscribe added in v0.8.0

func (c CalendarsEndpoint) APISubscribe(mytoken, calendarID string, req api.AddMytokenToCalendarRequest) (resp api.OnlyTokenUpdateResponse, err error)

APISubscribe subscribes a mytoken to a calendar

func (CalendarsEndpoint) APIUnsubscribe added in v0.8.0

func (c CalendarsEndpoint) APIUnsubscribe(mytoken, calendarID, momID string) (resp api.OnlyTokenUpdateResponse, err error)

APIUnsubscribe unsubscribes from a calendar

func (CalendarsEndpoint) APIUpdate added in v0.8.0

func (c CalendarsEndpoint) APIUpdate(mytoken, calendarID string, req api.CreateCalendarRequest) (resp api.OnlyTokenUpdateResponse, err error)

APIUpdate updates calendar description and/or tags

func (CalendarsEndpoint) DoHTTPRequest added in v0.8.0

func (c CalendarsEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the calendars endpoint

func (CalendarsEndpoint) DoHTTPRequestWithAuth added in v0.8.0

func (c CalendarsEndpoint) DoHTTPRequestWithAuth(method string, req, resp interface{}, mytoken string) error

DoHTTPRequestWithAuth performs an http request to the calendars endpoint with mytoken authorization

type EmailSettingsEndpoint added in v0.8.0

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

EmailSettingsEndpoint is type representing a mytoken server's Email Settings Endpoint

func (EmailSettingsEndpoint) APIGet added in v0.8.0

func (e EmailSettingsEndpoint) APIGet(mytoken string) (resp api.MailSettingsInfoResponse, err error)

APIGet retrieves the user's email settings information

func (EmailSettingsEndpoint) APIUpdate added in v0.8.0

func (e EmailSettingsEndpoint) APIUpdate(mytoken, emailAddress string, preferHTMLMail *bool) (resp api.OnlyTokenUpdateResponse, err error)

APIUpdate updates the user's email settings

func (EmailSettingsEndpoint) DoHTTPRequest added in v0.8.0

func (e EmailSettingsEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the email settings endpoint

func (EmailSettingsEndpoint) DoHTTPRequestWithAuth added in v0.8.0

func (e EmailSettingsEndpoint) DoHTTPRequestWithAuth(method string, req, resp interface{}, mytoken string) error

DoHTTPRequestWithAuth performs an http request to the email settings endpoint with mytoken authorization

type Endpoint added in v0.3.0

type Endpoint interface {
	DoHTTPRequest(method string, req interface{}, resp interface{}) error
}

Endpoint is an interface for mytoken endpoints

type GrantsEndpoint added in v0.3.0

type GrantsEndpoint struct {
	SSH *SSHGrantEndpoint
	// contains filtered or unexported fields
}

GrantsEndpoint is type representing a mytoken server's grants Endpoint and the actions that can be performed there.

func (GrantsEndpoint) APIDisableGrant added in v0.3.0

func (g GrantsEndpoint) APIDisableGrant(mytoken, grant string) (resp api.OnlyTokenUpdateResponse, err error)

APIDisableGrant disables the passed grant for this user. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.OnlyTokenUpdateResponse

func (GrantsEndpoint) APIEnableGrant added in v0.3.0

func (g GrantsEndpoint) APIEnableGrant(mytoken, grant string) (resp api.OnlyTokenUpdateResponse, err error)

APIEnableGrant enables the passed grant for this user. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.OnlyTokenUpdateResponse

func (GrantsEndpoint) APIGet added in v0.3.0

func (g GrantsEndpoint) APIGet(mytoken string) (resp api.GrantTypeInfoResponse, err error)

APIGet returns the api.GrantTypeInfoResponse about the enabled grant types for this user. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.GrantTypeInfoResponse

func (GrantsEndpoint) DisableGrant added in v0.3.0

func (g GrantsEndpoint) DisableGrant(mytoken *string, grant string) (err error)

DisableGrant disables the passed grant for this user. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (GrantsEndpoint) DoHTTPRequest added in v0.3.0

func (g GrantsEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the grants endpoint

func (GrantsEndpoint) DoHTTPRequestWithAuth added in v0.3.0

func (g GrantsEndpoint) DoHTTPRequestWithAuth(method string, req, resp interface{}, mytoken string) error

DoHTTPRequestWithAuth performs an http request to the grants endpoint

func (GrantsEndpoint) EnableGrant added in v0.3.0

func (g GrantsEndpoint) EnableGrant(mytoken *string, grant string) (err error)

EnableGrant enables the passed grant for this user. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (GrantsEndpoint) Get added in v0.3.0

func (g GrantsEndpoint) Get(mytoken *string) ([]api.GrantTypeInfo, error)

Get returns a slice of api.GrantTypeInfo about the enabled grant types for this user. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

type MytokenEndpoint added in v0.3.0

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

MytokenEndpoint is type representing a mytoken server's Mytoken Endpoint and the actions that can be performed there.

func (MytokenEndpoint) APIFromAuthorizationFlow added in v0.3.0

func (my MytokenEndpoint) APIFromAuthorizationFlow(
	issuer string, restrictions api.Restrictions, capabilities api.Capabilities,
	rotation *api.Rotation, responseType, name, applicationName string, callbacks PollingCallbacks,
) (api.MytokenResponse, error)

APIFromAuthorizationFlow is a rather high level function that obtains a new mytoken using the authorization code flow. This function starts the flow with the passed parameters and performs the polling for the mytoken. The passed PollingCallbacks are called throughout the flow.

func (MytokenEndpoint) APIFromAuthorizationFlowReq added in v0.6.0

func (my MytokenEndpoint) APIFromAuthorizationFlowReq(
	req api.GeneralMytokenRequest, callbacks PollingCallbacks,
) (api.MytokenResponse, error)

APIFromAuthorizationFlowReq is a rather high level function that obtains a new mytoken using the authorization code flow. This function starts the flow with the passed request and performs the polling for the mytoken. The passed PollingCallbacks are called throughout the flow.

func (MytokenEndpoint) APIFromMytoken added in v0.3.0

func (my MytokenEndpoint) APIFromMytoken(
	mytoken string, issuer string, restrictions api.Restrictions, capabilities api.Capabilities, rotation *api.Rotation,
	responseType, name string,
) (api.MytokenResponse, error)

APIFromMytoken obtains a sub-mytoken by using an existing mytoken according to the passed parameters. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.MytokenResponse

func (MytokenEndpoint) APIFromRequest added in v0.3.0

func (my MytokenEndpoint) APIFromRequest(request interface{}) (resp api.MytokenResponse, err error)

APIFromRequest sends the passed request marshalled as json to the servers mytoken endpoint to obtain a mytoken and returns the api.MytokenResponse.

func (MytokenEndpoint) APIFromTransferCode added in v0.3.0

func (my MytokenEndpoint) APIFromTransferCode(transferCode string) (api.MytokenResponse, error)

APIFromTransferCode exchanges the transferCode into the linked mytoken

func (MytokenEndpoint) APIInitAuthorizationFlow added in v0.3.0

func (my MytokenEndpoint) APIInitAuthorizationFlow(req api.GeneralMytokenRequest) (
	resp api.AuthCodeFlowResponse, err error,
)

APIInitAuthorizationFlow starts the authorization code flow to obtain a mytoken with the passed parameters; it returns the api.AuthCodeFlowResponse

func (MytokenEndpoint) APIPoll added in v0.3.0

func (my MytokenEndpoint) APIPoll(res api.PollingInfo, callback func(int64, int)) (*api.MytokenResponse, error)

APIPoll performs the polling for the final mytoken in the authorization code flow using the passed api.PollingInfo. The callback function takes the polling interval and the number of iteration as parameters; it is called for each polling attempt where the final mytoken could not yet be obtained (but no error occurred); it is usually used to print progress output. At the end the api.MytokenResponse is returned.

func (MytokenEndpoint) APIPollOnce added in v0.3.0

func (my MytokenEndpoint) APIPollOnce(pollingCode string) (*api.MytokenResponse, error)

APIPollOnce sends a single polling request with the passed pollingCode; it returns the api. MytokenResponse if obtained, or an error if an error occurred.

func (MytokenEndpoint) DoHTTPRequest added in v0.3.0

func (my MytokenEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the mytoken endpoint

func (MytokenEndpoint) FromAuthorizationFlow added in v0.3.0

func (my MytokenEndpoint) FromAuthorizationFlow(
	issuer string, restrictions api.Restrictions, capabilities api.Capabilities,
	rotation *api.Rotation, responseType, name, applicationName string, callbacks PollingCallbacks,
) (string, error)

FromAuthorizationFlow is a rather high level function that obtains a new mytoken using the authorization code flow. This function starts the flow with the passed parameters and performs the polling for the mytoken. The passed PollingCallbacks are called throughout the flow.

func (MytokenEndpoint) FromMytoken added in v0.3.0

func (my MytokenEndpoint) FromMytoken(
	mytoken *string, issuer string, restrictions api.Restrictions, capabilities api.Capabilities,
	rotation *api.Rotation, responseType, name string,
) (string, error)

FromMytoken obtains a sub-mytoken by using an existing mytoken according to the passed parameters. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (MytokenEndpoint) FromRequest added in v0.3.0

func (my MytokenEndpoint) FromRequest(request interface{}) (string, *string, error)

FromRequest sends the passed request marshalled as json to the servers mytoken endpoint to obtain a mytoken and returns the obtained mytoken and if a mytoken was used for authorization and it was rotated the updated mytoken.

func (MytokenEndpoint) FromTransferCode added in v0.3.0

func (my MytokenEndpoint) FromTransferCode(transferCode string) (string, error)

FromTransferCode exchanges the transferCode into the linked mytoken

func (MytokenEndpoint) Poll added in v0.3.0

func (my MytokenEndpoint) Poll(res api.PollingInfo, callback func(int64, int)) (string, error)

Poll performs the polling for the final mytoken in the authorization code flow using the passed api.PollingInfo. The callback function takes the polling interval and the number of iteration as parameters; it is called for each polling attempt where the final mytoken could not yet be obtained (but no error occurred); it is usually used to print progress output. At the end the mytoken is returned.

func (MytokenEndpoint) PollOnce added in v0.3.0

func (my MytokenEndpoint) PollOnce(pollingCode string) (string, bool, error)

PollOnce sends a single polling request with the passed pollingCode; it returns the mytoken if obtained, a bool indicating if the mytoken was obtained, or an error if an error occurred.

func (MytokenEndpoint) Tags added in v0.8.0

Tags returns the tags sub-endpoint for the mytoken endpoint

type MytokenError

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

MytokenError is a error type from the mytoken library

func (MytokenError) Error

func (err MytokenError) Error() string

Error implements the error interface and returns a string representation of this MytokenError

type MytokenServer added in v0.3.0

type MytokenServer struct {
	ServerMetadata       api.MytokenConfiguration
	AccessToken          *AccessTokenEndpoint
	Mytoken              *MytokenEndpoint
	Revocation           *RevocationEndpoint
	Tokeninfo            *TokeninfoEndpoint
	Transfer             *TransferEndpoint
	UserSettings         *UserSettingsEndpoint
	Notifications        *NotificationsEndpoint
	Calendars            *CalendarsEndpoint
	ProfilesAndTemplates *ProfilesAndTemplatesEndpoint
}

MytokenServer is a type describing a mytoken server instance

func NewMytokenServer added in v0.3.0

func NewMytokenServer(url string) (*MytokenServer, error)

NewMytokenServer creates a new MytokenServer

type MytokenTagsEndpoint added in v0.8.0

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

MytokenTagsEndpoint is a type representing the Mytoken Tags sub-endpoint

func (MytokenTagsEndpoint) APIAdd added in v0.8.0

APIAdd adds a tag to a mytoken

func (MytokenTagsEndpoint) APIRemove added in v0.8.0

APIRemove removes a tag from a mytoken

type NotificationsEndpoint added in v0.8.0

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

NotificationsEndpoint is type representing a mytoken server's Notifications Endpoint

func (NotificationsEndpoint) APIAddToken added in v0.8.0

func (n NotificationsEndpoint) APIAddToken(mytoken, managementCode string, req api.NotificationAddTokenRequest) (resp api.OnlyTokenUpdateResponse, err error)

APIAddToken adds a token to a notification

func (NotificationsEndpoint) APICreate added in v0.8.0

APICreate creates a new notification subscription

func (NotificationsEndpoint) APIDelete added in v0.8.0

func (n NotificationsEndpoint) APIDelete(mytoken, managementCode string) (resp api.OnlyTokenUpdateResponse, err error)

APIDelete deletes a notification by management code

func (NotificationsEndpoint) APIList added in v0.8.0

func (n NotificationsEndpoint) APIList(mytoken string) (resp api.NotificationsListResponse, err error)

APIList lists all notifications

func (NotificationsEndpoint) APIRemoveToken added in v0.8.0

func (n NotificationsEndpoint) APIRemoveToken(mytoken, managementCode string, req api.NotificationRemoveTokenRequest) (resp api.OnlyTokenUpdateResponse, err error)

APIRemoveToken removes a token from a notification

func (NotificationsEndpoint) APIUpdate added in v0.8.0

func (n NotificationsEndpoint) APIUpdate(mytoken, managementCode string, req api.NotificationUpdateRequest) (resp api.OnlyTokenUpdateResponse, err error)

APIUpdate updates notification classes and/or tags

func (NotificationsEndpoint) DoHTTPRequest added in v0.8.0

func (n NotificationsEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the notifications endpoint

func (NotificationsEndpoint) DoHTTPRequestWithAuth added in v0.8.0

func (n NotificationsEndpoint) DoHTTPRequestWithAuth(method string, req, resp interface{}, mytoken string) error

DoHTTPRequestWithAuth performs an http request to the notifications endpoint with mytoken authorization

type PollingCallbacks

type PollingCallbacks struct {
	Init     func(string) error
	Callback func(int64, int)
	End      func()
}

PollingCallbacks is a struct holding callback related to the polling in the authorization code flow. The Init function takes the authorization url and is called before starting polling the server; this callback usually displays information to the user how to proceed, including the passed authorization url The Callback function takes the polling interval and the number of iteration as parameters; it is called for each polling attempt where the final mytoken could not yet be obtained (but no error occurred); it is usually used to print progress output. The End function is called after the mytoken was successfully obtained and might be used to finish output printed to the user.

type ProfilesAndTemplatesEndpoint added in v0.8.0

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

ProfilesAndTemplatesEndpoint is type representing a mytoken server's Profiles and Templates Endpoint

func (ProfilesAndTemplatesEndpoint) APIGetCapabilities added in v0.8.0

func (p ProfilesAndTemplatesEndpoint) APIGetCapabilities(group string) ([]api.Profile, error)

APIGetCapabilities retrieves capability templates for a group

func (ProfilesAndTemplatesEndpoint) APIGetGroups added in v0.8.0

func (p ProfilesAndTemplatesEndpoint) APIGetGroups() ([]string, error)

APIGetGroups retrieves all available profile groups

func (ProfilesAndTemplatesEndpoint) APIGetProfiles added in v0.8.0

func (p ProfilesAndTemplatesEndpoint) APIGetProfiles(group string) ([]api.Profile, error)

APIGetProfiles retrieves profiles for a group

func (ProfilesAndTemplatesEndpoint) APIGetRestrictions added in v0.8.0

func (p ProfilesAndTemplatesEndpoint) APIGetRestrictions(group string) ([]api.Profile, error)

APIGetRestrictions retrieves restriction templates for a group

func (ProfilesAndTemplatesEndpoint) APIGetRotation added in v0.8.0

func (p ProfilesAndTemplatesEndpoint) APIGetRotation(group string) ([]api.Profile, error)

APIGetRotation retrieves rotation templates for a group

func (ProfilesAndTemplatesEndpoint) DoHTTPRequest added in v0.8.0

func (p ProfilesAndTemplatesEndpoint) DoHTTPRequest(method string, req, resp interface{}, pathSuffix ...string) error

DoHTTPRequest performs an http request to the profiles and templates endpoint

type RevocationEndpoint added in v0.3.0

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

RevocationEndpoint is type representing a mytoken server's Revocation Endpoint and the actions that can be performed there.

func (RevocationEndpoint) DoHTTPRequest added in v0.3.0

func (r RevocationEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the revocation endpoint

func (RevocationEndpoint) Revoke added in v0.3.0

func (r RevocationEndpoint) Revoke(mytoken, oidcIssuer string, recursive bool) error

Revoke revokes the passed mytoken; if recursive is true also all subtokens (and their subtokens...) are revoked.

func (RevocationEndpoint) RevokeID added in v0.4.0

func (r RevocationEndpoint) RevokeID(momID, mytoken, oidcIssuer string, recursive bool) error

RevokeID revokes the mytoken with the passed mom id; using the passed mytoken as authorization; if recursive is true also all subtokens (and their subtokens...) are revoked.

type SSHGrantEndpoint added in v0.3.0

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

SSHGrantEndpoint is type representing a mytoken server's ssh grant Endpoint and the actions that can be performed there.

func (SSHGrantEndpoint) APIAdd added in v0.3.0

func (s SSHGrantEndpoint) APIAdd(
	mytoken, sshKey, name string, restrictions api.Restrictions, capabilities api.Capabilities,
	callbacks PollingCallbacks,
) (response api.SSHKeyAddFinalResponse, tokenUpdate *api.MytokenResponse, err error)

APIAdd is a rather high level function to add a new ssh key; this includes sending the initial request including the public key, starting the necessary authorization code flow. This function starts the flow with the passed parameters and performs the polling for the ssh username and configuration. The passed PollingCallbacks are called throughout the flow. If the used mytoken changes (due to token rotation), the new mytoken is returned in the non-nil *api.MytokenResponse

func (SSHGrantEndpoint) APIGet added in v0.3.0

func (s SSHGrantEndpoint) APIGet(mytoken string) (resp api.SSHInfoResponse, err error)

APIGet returns the api.SSHInfoResponse for this user. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.SSHInfoResponse

func (SSHGrantEndpoint) APIInitAddSSHKey added in v0.3.0

func (s SSHGrantEndpoint) APIInitAddSSHKey(
	mytoken, sshKey, name string, restrictions api.Restrictions, capabilities api.Capabilities,
) (resp api.SSHKeyAddResponse, err error)

APIInitAddSSHKey starts the flow to add an ssh key; it returns the api.AuthCodeFlowResponse

func (SSHGrantEndpoint) APIPoll added in v0.3.0

func (s SSHGrantEndpoint) APIPoll(res api.PollingInfo, callback func(int64, int)) (*api.SSHKeyAddFinalResponse, error)

APIPoll performs the polling for the final ssh username in the add ssh key flow using the passed api.PollingInfo. The callback function takes the polling interval and the number of iteration as parameters; it is called for each polling attempt where the final mytoken could not yet be obtained (but no error occurred); it is usually used to print progress output. At the end the api.SSHKeyAddFinalResponse is returned.

func (SSHGrantEndpoint) APIPollOnce added in v0.3.0

func (s SSHGrantEndpoint) APIPollOnce(pollingCode string) (*api.SSHKeyAddFinalResponse, error)

APIPollOnce sends a single polling request with the passed pollingCode; it returns the api.SSHKeyAddFinalResponse if obtained, or an error if an error occurred.

func (SSHGrantEndpoint) APIRemove added in v0.3.0

func (s SSHGrantEndpoint) APIRemove(mytoken, keyFP, publicKey string) (resp api.OnlyTokenUpdateResponse, err error)

APIRemove removes an ssh public key, therefore disabling it. One of keyFP and publicKey must be given, i.e. the ssh key can be deleted by giving only the SHA256 fingerprint or the full public key. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.OnlyTokenUpdateResponse

func (SSHGrantEndpoint) Add added in v0.3.0

func (s SSHGrantEndpoint) Add(
	mytoken *string, sshKey, name string, restrictions api.Restrictions, capabilities api.Capabilities,
	callbacks PollingCallbacks,
) (api.SSHKeyAddFinalResponse, error)

Add is a rather high level function to add a new ssh key; this includes sending the initial request including the public key, starting the necessary authorization code flow. This function starts the flow with the passed parameters and performs the polling for the ssh username and configuration. The passed PollingCallbacks are called throughout the flow. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (SSHGrantEndpoint) DoHTTPRequest added in v0.3.0

func (s SSHGrantEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the ssh grant endpoint

func (SSHGrantEndpoint) DoHTTPRequestWithAuth added in v0.3.0

func (s SSHGrantEndpoint) DoHTTPRequestWithAuth(
	method string, req interface{}, resp interface{}, mytoken string,
) error

DoHTTPRequestWithAuth performs an http request to the ssh grant endpoint

func (SSHGrantEndpoint) Get added in v0.3.0

func (s SSHGrantEndpoint) Get(mytoken *string) ([]api.SSHKeyInfo, bool, error)

Get returns a slice of api.SSHKeyInfo about the enabled ssh keys for this user and a bool indicating if the ssh grant is enabled or not. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (SSHGrantEndpoint) Remove added in v0.3.0

func (s SSHGrantEndpoint) Remove(mytoken *string, keyFP, publicKey string) error

Remove removes an ssh public key, therefore disabling it. One of keyFP and publicKey must be given, i.e. the ssh key can be deleted by giving only the SHA256 fingerprint or the full public key. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

type TagsSettingsEndpoint added in v0.8.0

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

TagsSettingsEndpoint is type representing a mytoken server's Tags Settings Endpoint

func (TagsSettingsEndpoint) APICreate added in v0.8.0

func (t TagsSettingsEndpoint) APICreate(mytoken, tagName, color string) (err error)

APICreate creates a new tag with optional color

func (TagsSettingsEndpoint) APIDelete added in v0.8.0

func (t TagsSettingsEndpoint) APIDelete(mytoken, tagName string) (resp api.OnlyTokenUpdateResponse, err error)

APIDelete deletes a tag

func (TagsSettingsEndpoint) APIGet added in v0.8.0

func (t TagsSettingsEndpoint) APIGet(mytoken string) (resp api.TagListingResponse, err error)

APIGet retrieves the user's tags

func (TagsSettingsEndpoint) APIUpdate added in v0.8.0

func (t TagsSettingsEndpoint) APIUpdate(mytoken, tagName, newTagName, color string) (resp api.OnlyTokenUpdateResponse, err error)

APIUpdate updates an existing tag

func (TagsSettingsEndpoint) DoHTTPRequest added in v0.8.0

func (t TagsSettingsEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the tags settings endpoint

func (TagsSettingsEndpoint) DoHTTPRequestWithAuth added in v0.8.0

func (t TagsSettingsEndpoint) DoHTTPRequestWithAuth(method string, req, resp interface{}, mytoken string) error

DoHTTPRequestWithAuth performs an http request to the tags settings endpoint with mytoken authorization

type TokeninfoEndpoint added in v0.3.0

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

TokeninfoEndpoint is type representing a mytoken server's Revocation Endpoint and the actions that can be performed there.

func (TokeninfoEndpoint) APIHistory added in v0.3.0

func (info TokeninfoEndpoint) APIHistory(mytoken string, momIDs ...string) (
	resp api.TokeninfoHistoryResponse, err error,
)

APIHistory obtains the event history for the passed mytoken or mom ids. If the used mytoken changes (due to token rotation), the new mytoken is included in the api.TokeninfoHistoryResponse

func (TokeninfoEndpoint) APIListMytokens added in v0.3.0

func (info TokeninfoEndpoint) APIListMytokens(mytoken string) (resp api.TokeninfoListResponse, err error)

APIListMytokens returns an api.TokeninfoListResponse listing metadata about all the user's mytoken and their children (recursively) If the used mytoken changes (due to token rotation), the new mytoken is included in the api.TokeninfoListResponse

func (TokeninfoEndpoint) APINotifications added in v0.8.0

func (info TokeninfoEndpoint) APINotifications(mytoken string, momIDs []string) (
	resp api.NotificationsCombinedResponse, err error,
)

APINotifications returns notifications and calendars for the passed mytoken or mom ids. If the used mytoken changes (due to token rotation), the new mytoken is included in the response

func (TokeninfoEndpoint) APISubtokens added in v0.3.0

func (info TokeninfoEndpoint) APISubtokens(mytoken string) (resp api.TokeninfoSubtokensResponse, err error)

APISubtokens returns an api.TokeninfoTreeResponse listing metadata about the passed mytoken and its children ( recursively) If the used mytoken changes (due to token rotation), the new mytoken is included in the api.TokeninfoTreeResponse

func (TokeninfoEndpoint) DoHTTPRequest added in v0.3.0

func (info TokeninfoEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the tokeninfo endpoint

func (TokeninfoEndpoint) History added in v0.3.0

func (info TokeninfoEndpoint) History(mytoken *string) ([]api.EventEntry, error)

History obtains the event history for the passed mytoken. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (TokeninfoEndpoint) HistoryForOtherMytoken added in v0.7.0

func (info TokeninfoEndpoint) HistoryForOtherMytoken(mytoken *string, momID string) (*api.EventHistory, error)

HistoryForOtherMytoken obtains the event history for mytoken with the passed mom id and uses the passed mytoken as authorization. If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (TokeninfoEndpoint) Introspect added in v0.3.0

func (info TokeninfoEndpoint) Introspect(mytoken string) (*api.TokeninfoIntrospectResponse, error)

Introspect introspects the passed mytoken

func (TokeninfoEndpoint) ListMytokens added in v0.3.0

func (info TokeninfoEndpoint) ListMytokens(mytoken *string) ([]api.MytokenEntryTree, error)

ListMytokens returns a slice of api.MytokenEntryTree listing metadata about all the user's mytoken and their children (recursively) If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

func (TokeninfoEndpoint) Subtokens added in v0.3.0

func (info TokeninfoEndpoint) Subtokens(mytoken *string) (*api.MytokenEntryTree, error)

Subtokens returns an api.MytokenEntryTree listing metadata about the passed mytoken and its children ( recursively) If the used mytoken changes (due to token rotation), the passed variable is updated accordingly.

type TransferEndpoint added in v0.3.0

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

TransferEndpoint is type representing a mytoken server's Token Transfer Endpoint and the actions that can be performed there.

func (TransferEndpoint) APICreate added in v0.3.0

func (t TransferEndpoint) APICreate(mytoken string) (api.TransferCodeResponse, error)

APICreate creates a new transfer code for the passed mytoken and returns the api response

func (TransferEndpoint) Create added in v0.3.0

func (t TransferEndpoint) Create(mytoken string) (string, error)

Create creates a new transfer code for the passed mytoken

func (TransferEndpoint) DoHTTPRequest added in v0.3.0

func (t TransferEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the token transfer endpoint

type UserSettingsEndpoint added in v0.3.0

type UserSettingsEndpoint struct {
	Grants *GrantsEndpoint
	Email  *EmailSettingsEndpoint
	Tags   *TagsSettingsEndpoint
	// contains filtered or unexported fields
}

UserSettingsEndpoint is type representing a mytoken server's User Settings Endpoint and the actions that can be performed there.

func (UserSettingsEndpoint) DoHTTPRequest added in v0.3.0

func (s UserSettingsEndpoint) DoHTTPRequest(method string, req, resp interface{}) error

DoHTTPRequest performs an http request to the user settings endpoint

func (UserSettingsEndpoint) MetaData added in v0.3.0

MetaData returns the user settings endpoint's api.SettingsMetaData

Jump to

Keyboard shortcuts

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