server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserClaims         = "user_claims"
	AccessTokenCookie  = "access_token"
	RefreshTokenCookie = "refresh_token"
)

Variables

This section is empty.

Functions

func GetAccessToken

func GetAccessToken(c *gin.Context) (tks string, err error)

func GetUserClaims

func GetUserClaims(c *gin.Context) (*tokens.Claims, error)

func GetUserID

func GetUserID(c *gin.Context) (int64, error)

func SetAuthCookies added in v0.3.0

func SetAuthCookies(c *gin.Context, accessToken, refreshToken, domain string) (err error)

SetAuthCookies is a helper function that sets access and refresh token cookies on a gin request. The access token cookie (access_token) is an http only cookie that expires when the access token expires. The refresh token cookie is an http only cookie (it can't be accessed by client-side scripts) and it expires when the refresh token expires. Both cookies require https and will not be set (silently) over http.

Types

type Server

type Server struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(conf config.Config) (s *Server, err error)

New creates a new Epistolary server from the specified configuration.

func (*Server) Authenticate

func (s *Server) Authenticate(c *gin.Context)

func (*Server) Authorize

func (s *Server) Authorize(permissions ...string) gin.HandlerFunc

func (*Server) Available

func (s *Server) Available() gin.HandlerFunc

Available is middleware that uses the healthy boolean to return a service unavailable http status code if the server is shutting down. This middleware must be first in the chain to ensure that complex handling to slow the shutdown of the server.

func (*Server) CreateReading

func (s *Server) CreateReading(c *gin.Context)

func (*Server) DeleteReading

func (s *Server) DeleteReading(c *gin.Context)

func (*Server) FetchReading

func (s *Server) FetchReading(c *gin.Context)

func (*Server) JWKS

func (s *Server) JWKS(c *gin.Context)

JWKS returns the JSON web key set for the public RSA keys that are currently being used by Epistolary to sign JWT acccess and refresh tokens. External callers can use these keys to verify that a JWT token was in fact issued by the Epistolary API.

func (*Server) ListReadings

func (s *Server) ListReadings(c *gin.Context)

func (*Server) Login

func (s *Server) Login(c *gin.Context)

func (*Server) Logout added in v0.3.0

func (s *Server) Logout(c *gin.Context)

func (*Server) OpenIDConfiguration

func (s *Server) OpenIDConfiguration(c *gin.Context)

Returns a JSON document with the OpenID configuration as defined by the OpenID Connect standard: https://connect2id.com/learn/openid-connect. This document helps clients understand how to authenticate with Epistolary. TODO: once OpenID endpoints have been configured add them to this JSON response

func (*Server) Register

func (s *Server) Register(c *gin.Context)

func (*Server) SecurityTxt

func (s *Server) SecurityTxt(c *gin.Context)

Writes the security.txt file generated from https://securitytxt.org/ and digitally signed with the info@rotational.io PGP keys to alert security researchers to our security policies and allow them to contact us with any security flaws.

func (*Server) Serve

func (s *Server) Serve() (err error)

Serve API requests on the specified address.

func (*Server) SetHealth

func (s *Server) SetHealth(health bool)

func (*Server) SetURL

func (s *Server) SetURL(url string)

func (*Server) Shutdown

func (s *Server) Shutdown() (err error)

func (*Server) Status

func (s *Server) Status(c *gin.Context)

func (*Server) URL

func (s *Server) URL() string

func (*Server) UpdateReading

func (s *Server) UpdateReading(c *gin.Context)

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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