server

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package server provides utility functions to make it easier to integrate Cord into your application.

For more information about the Cord-specific terms used here, see the concepts documentation at https://docs.cord.com/concepts/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationManagementAuthToken added in v0.0.2

func ApplicationManagementAuthToken(customerID string, secret []byte) (string, error)

ApplicationManagementAuthToken returns a server side auth token suitable for authenticating requests to Cord's Applications REST API (see https://docs.cord.com/reference/rest-api/).

func ClientAuthToken

func ClientAuthToken(appID string, secret []byte, data ClientAuthTokenData) (string, error)

ClientAuthToken returns a client auth token suitable for authenticating a user to Cord.

func ServerAuthToken

func ServerAuthToken(appID string, secret []byte) (string, error)

ServerAuthToken returns a server auth token suitable for authenticating requests to Cord's REST API (see https://docs.cord.com/reference/rest-api/).

Types

type ClientAuthTokenData

type ClientAuthTokenData struct {
	UserID              string
	OrganizationID      string
	UserDetails         *UserDetails
	OrganizationDetails *OrganizationDetails
}

ClientAuthTokenData is the data that can be supplied in a client auth token.

type OrganizationDetails

type OrganizationDetails struct {
	Name    string   `json:"name"`
	Status  Status   `json:"status,omitempty"`
	Members []string `json:"members,omitempty"`
}

OrganizationDetails contains the information about an organization that needs to be synced to Cord. Any values that are left at their zero value are not sent except Name, which is required.

type Status

type Status int

A Status is the state of a user or organization.

const (
	Unspecified Status = iota
	Active
	Deleted // Deleted users or organizations will have authentication attempts refused
)

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Status to its text format

func (Status) String

func (s Status) String() string

String returns the string value of a Status for use in the API

type UserDetails

type UserDetails struct {
	Email             string `json:"email"`
	Name              string `json:"name,omitempty"`
	ProfilePictureURL string `json:"profile_picture_url,omitempty"`
	Status            Status `json:"status,omitempty"`
	FirstName         string `json:"first_name,omitempty"`
	LastName          string `json:"last_name,omitempty"`
}

UserDetails contains the information about a user that needs to be synced to Cord. Any values that are left at their zero value are not sent except Email, which is required.

Jump to

Keyboard shortcuts

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