Documentation ¶
Index ¶
- Constants
- func AuthWall() gin.HandlerFunc
- func CreateApplication(con *gin.Context)
- func DeleteApplication(con *gin.Context)
- func DeleteToken(uuid string)
- func ExtractToken(r *http.Request) string
- func GetAbsenceFormForClasses(con *gin.Context)
- func GetAbsenceFormForTeacher(con *gin.Context)
- func GetActiveApplications(con *gin.Context)
- func GetAdminApplications(con *gin.Context)
- func GetAllApplications(con *gin.Context)
- func GetApplication(con *gin.Context)
- func GetBusinessTripApplicationExcel(con *gin.Context)
- func GetBusinessTripApplicationForm(con *gin.Context)
- func GetCompensationForEducationalSupportForm(con *gin.Context)
- func GetNews(con *gin.Context)
- func GetTeacher(con *gin.Context)
- func GetTeacherByShort(con *gin.Context)
- func GetTeacherByUntis(con *gin.Context)
- func GetTravelInvoiceExcel(con *gin.Context)
- func GetTravelInvoiceForm(con *gin.Context)
- func InitTokenManager()
- func Login(con *gin.Context)
- func Logout(con *gin.Context)
- func Refresh(con *gin.Context)
- func SaveBillingReceipt(con *gin.Context)
- func SaveToken(username string, token *Token)
- func SetTeacherPermissions(con *gin.Context)
- func StartService()
- func TokenValid(r *http.Request) (bool, error)
- func UpdateApplication(con *gin.Context)
- func UpdateTeacherInformation(con *gin.Context)
- func VerifyToken(r *http.Request) (*jwt.Token, error)
- type AccessToken
- type EntityInformation
- type Error
- type Excel
- type Information
- type News
- type PDF
- type PDFs
- type Permissions
- type RefreshToken
- type TeacherInformation
- type Token
- type TokenPair
- type User
Constants ¶
const DebugFilePath = "/vol/files/.debug"
DebugFilePath to where a .debug file lies
const Port = 8080
Port is the port this api will listen to
Variables ¶
This section is empty.
Functions ¶
func AuthWall ¶
func AuthWall() gin.HandlerFunc
AuthWall drops every token which doesnt provide a valid token
func CreateApplication ¶
CreateApplication represents the create applications endpoint @Summary Creates a new application @Description Creates the provided application in the system @ID create-application @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param application body db.Application true "The Application Data" @Success 200 {object} Information @Failure 401 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /createApplication [post]
func DeleteApplication ¶
DeleteApplication represents the delete applications endpoint @Summary Deletes an existing application @Description Deletes an application identified by a uuid @ID delete-application @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to delete" @Success 200 {object} Information @Failure 401 {object} Error @Failure 404 {object Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /deleteApplication [delete]
func ExtractToken ¶
ExtractToken parses the token string out of a request
func GetAbsenceFormForClasses ¶
GetAbsenceFormForClasses represents get absence form for classes endpoint @Summary Generates an absence form for classes @Description Generates an absence form for classes and returns it @ID get-absence-form-for-classes @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the pdf from" @Param classes query []string false "Filter for classes" @Success 200 {object} PDF @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getAbsenceFormForClasses [get]
func GetAbsenceFormForTeacher ¶
GetAbsenceFormForTeacher represents get absence form for teacher endpoint @Summary Generates an absence form for a teacher @Description Generates an absence form for a teacher and returns it @ID get-absence-form-for-teacher @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the pdf from" @Param teacher query string false "short name of the teacher, if not provided logged in teacher will be used" @Success 200 {object} PDF @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getAbsenceFormForTeacher [get]
func GetActiveApplications ¶
GetActiveApplications represents the get active applications endpoint @Summary Returns all active applications @Description Returns all active applications as a list of applications @ID get-all-active-applications @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param username query string false "Filter to only show applications of this teacher" @Success 200 {array} db.Application @Failure 401 {object} Error @Failure 500 {object} Error @Router /getActiveApplications [get]
func GetAdminApplications ¶
GetAdminApplications represents the get admin applications endpoint @Summary Returns all admin applications @Description Returns all applications currently needing a review by an admin @ID get-admin-applications @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Success 200 {array} db.Application @Failure 401 {object} Error @Failure 500 {object} Error @Router /getAdminApplication [get]
func GetAllApplications ¶
GetAllApplications represents the get all applications endpoint @Summary Returns all applications @Description Returns all applications as a list of applications @ID get-all-applications @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param username query string false "Filter to only show applications of this teacher" @Success 200 {array} db.Application @Failure 401 {object} Error @Failure 500 {object} Error @Router /getAllApplications [get]
func GetApplication ¶
GetApplication represents the get application endpoint @Summary Returns an Application @Description Returns the Application matching the given UUID @ID get-application @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "The UUID of the specifying Application" @Success 200 {object} db.Application @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getApplication [get]
func GetBusinessTripApplicationExcel ¶
GetBusinessTripApplicationExcel represents get business application excel endpoint @Summary Generates a business trip application excel for a teacher @Description Generates a business trip application excel for a teacher and returns it @ID get-business-trip-application-excel @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the excel from" @Param short query string true "Short name of the teacher this should be generated for" @Param bta_id query int true "ID of the Business Trip Application data" @Success 200 {object} Excel @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getBusinessTripApplicationExcel [get]
func GetBusinessTripApplicationForm ¶
GetBusinessTripApplicationForm represents get business application form endpoint @Summary Generates a business trip application form for a teacher @Description Generates a business trip application form for a teacher and returns it @ID get-business-trip-application-form @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the form from" @Param short query string true "Short name of the teacher this should be generated for" @Param bta_id query int true "ID of the Business Trip Application data" @Success 200 {object} PDF @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getBusinessTripApplicationForm [get]
func GetCompensationForEducationalSupportForm ¶
GetCompensationForEducationalSupportForm represents get compensation for educational support form endpoint @Summary Generates a compensation for educational support form for all teachers @Description Generates a compensation for educational support form for all teachers and returns it @ID get-compensation-for-educational-support-form @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the pdf from" @Success 200 {object} PDF @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getCompensationForEducationalSupportForm [get]
func GetNews ¶
GetNews represents the get news endpoint @Summary Returns the news @Description Returns the 10 last changed applications @ID get-news @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Success 200 {array} News @Failure 401 {object} Error @Failure 500 {object} Error @Router /getNews [get]
func GetTeacher ¶
GetTeacher represents the get teacher endpoint @Summary Returns a teacher with the specified UUID @Description Searches for the Teacher with the specified uuid and returns the data @ID get-teacher @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "UUID of Teacher" @Success 200 {object} db.Teacher @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getTeacher [get]
func GetTeacherByShort ¶
GetTeacherByShort represents the get teacher by short name endpoint @Summary Returns a teacher with the specified short name @Description Searches for the Teacher with the specified name and returns the data @ID get-teacher-by-short @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param name query string true "Short Name of Teacher" @Success 200 {object} db.Teacher @Failure 401 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getTeacherByShort [get]
func GetTeacherByUntis ¶
GetTeacherByUntis represents the get teacher by untis endpoint @Summary Returns a teacher with the specified untis abbrevation @Description Searches for the Teacher with the specified untis abbrevation and returns the data @ID get-teacher-by-untis @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param untis query string true "Untis abbrevation of Teacher" @Success 200 {object} db.Teacher @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getTeacherByUntis [get]
func GetTravelInvoiceExcel ¶
GetTravelInvoiceExcel represents get travel invoice excel endpoint @Summary Generates a travel invoice excel for a teacher @Description Generates a travel invoice excel for a teacher and returns it @ID get-travel-invoice-excel @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the excel from" @Param short query string true "Short name of the teacher this should be generated for" @Param ti_id query int true "ID of the Travel Invoice data" @Success 200 {object} Excel @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getTravelInvoiceExcel [get]
func GetTravelInvoiceForm ¶
GetTravelInvoiceForm represents get travel invoice form endpoint @Summary Generates a travel invoice for a teacher @Description Generates a travel invoice form for a teacher and returns it @ID get-travel-invoice-form @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the pdf from" @Param short query string true "Short name of the teacher this should be generated for" @Param ti_id query int true "ID of the Travel Invoice data" @Param receipts query bool false "If provided the pdf will include all receipt" @Success 200 {object} PDF @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /getTravelInvoiceForm [get]
func InitTokenManager ¶
func InitTokenManager()
InitTokenManager initializes the token manager it reads or generates both secrets, creates the map of active tokens, and starts the thread to remove expired tokens
func Login ¶
Login represents the login endpoint @Summary Login a user @Description Login a user using username and password @ID login @Accept json @Produce json @Param user body User true "Account Information" @Success 200 {object} TokenPair @Failure 401 {object} Error @Failure 422 {object} Error @Router /login [post]
func Logout ¶
Logout represents the logout endpoint @Summary Logs out a user @Description Destroys the session of a user @ID logout @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Success 200 {object} Information @Failure 401 {object} Error @Router /logout [post]
func Refresh ¶
Refresh represents the refresh endpoint @Summary Refreshes the token pair of a session @Description Creates a new token pair when a valid refresh token is provided @ID refresh @Accept json @Produce json @Param token body RefreshToken true "Refresh Token" @Success 201 {object} TokenPair @Failure 401 {object} Error @Failure 403 {object} Error @Failure 422 {object} Error @Router /login/refresh [post]
func SaveBillingReceipt ¶
SaveBillingReceipt represents get save billing receipt endpoint @Summary Saves a billing receipt @Description Saves a billing receipt in the context of an application @ID save-billing-receipt @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param uuid query string true "Identifier of the application to generate the excel from" @Param short query string true "Short name of the teacher this should be generated for" @Param files body PDFs true "The files to save as an array of the base64 decoded file contents" @Success 200 {object} Information @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /saveBillingReceipt [post]
func SaveToken ¶
SaveToken saves a token in the active token map with its corresponding username as key
func SetTeacherPermissions ¶
SetTeacherPermissions represents the set teacher permissions endpoint @Summary Sets the permissions of a Teacher @Description Sets the permissions of a Teacher to update their access rights @ID set-teacher-permissions @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param perm body Permissions true "Permission data of the teacher" @Param uuid query string true "UUID of the teacher whos permissions will be changed" @Success 200 {object} db.Teacher @Failure 401 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /setTeacherPermissions [post]
func StartService ¶
func StartService()
StartService starts the rest service @title Refundable @version 1.1 @description This REST-API provides the backend of Refundable @contact.name Michael Beier - Entwickler @contact.url https://mbeier.at @contact.email admin@mbeier.at @securityDefinitions.apikey ApiKeyAuth @in header @name Authorization @license.name MIT License @license.url https://github.com/refundable-tgm/huginn/blob/master/LICENSE @host localhost:8080 @BasePath /api @query.collection.format multi
func TokenValid ¶
TokenValid checks whether a token is still valid, therefore also verifies it
func UpdateApplication ¶
UpdateApplication represents the update applications endpoint @Summary Updates an existing application @Description Updates an application identified by a uuid with the data in the body in the system @ID update-application @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param application body db.Application true "The application data to update" @Param uuid query string true "Identifier of the application to update" @Success 200 {object} Information @Failure 401 {object} Error @Failure 404 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /updateApplication [put]
func UpdateTeacherInformation ¶
UpdateTeacherInformation represents the update teacher information endpoint @Summary Updates the information of an existing teacher @Description Updates a teacher identified by a uuid with the data in the body in the system @ID update-teacher-information @Accept json @Produce json @Param Authorization header string true "Access Token" default(Bearer <Add access token here>) @Param teacher_information body rest.TeacherInformation true "The teacher information data to set" @Param uuid query string true "Identifier of the teacher to update" @Success 200 {object} Information @Failure 401 {object} Error @Failure 422 {object} Error @Failure 500 {object} Error @Router /updateTeacherInformation [put]
func VerifyToken ¶
VerifyToken verifies that the token provided in the request originates from this API
Types ¶
type AccessToken ¶
type AccessToken struct { // AccessUUID is the uuid of the access token AccessUUID string // Username is the username of the user this token belongs to Username string }
AccessToken represents the further information about an access token
func ExtractTokenMeta ¶
func ExtractTokenMeta(r *http.Request) (*AccessToken, error)
ExtractTokenMeta extracts the meta information encoded in the token and returns both uuid and username
type EntityInformation ¶
type EntityInformation struct { // Username identifies the user this token belongs to Username string // ExpiresAt marks the time the token expires at ExpiresAt time.Time }
EntityInformation represents information about tokens
type Error ¶
type Error struct { // the message that should be sent Message string `json:"error" example:"couldn't convert token"` }
Error maps an error message
type Excel ¶
type Excel struct { // Content is the content of the excel file Content string `json:"excel" example:"<base64>"` }
Excel represents an excel output
type Information ¶
type Information struct { // the message that should be sent Message string `json:"info" example:"updated teacher successfully"` }
Information maps an information message
type News ¶
type News struct { // UUID of the application UUID string `json:"uuid" example:"3fcf7f67-e0ed-4339-99b4-a6765aaa3dc4"` // Title of the application Title string `json:"title" example:"Sommersportwoche"` // State of the application State int `json:"state" example:"3"` // LastChanged is the date of last changes of the application LastChanged string `json:"last_changed" example:"2009-11-10 23:00:00 +0000 UTC m=+0.000000001"` }
News is a news object for applications
type PDF ¶
type PDF struct { // Content is the content of this file Content string `json:"pdf" example:"<base64>"` }
PDF represents a pdf file
type Permissions ¶
type Permissions struct { // SuperUser permission SuperUser bool `json:"super_user" example:"true"` // Administration permission Administration bool `json:"administration" example:"true"` // AV permission AV bool `json:"av" example:"true"` // PEK permission PEK bool `json:"pek" example:"true"` }
Permissions lists the permissions of a teacher
type RefreshToken ¶
type RefreshToken struct { // Token is the refresh token Token string `json:"refresh_token" example:"<jwt-token>"` }
RefreshToken maps an refresh token
type TeacherInformation ¶
type TeacherInformation struct { // Degree of the Teacher Degree string `json:"degree" example:"DI"` // Title of the Teacher Title string `json:"title" example:"Prof"` // The Staffnr of the regarding teacher Staffnr int `json:"staffnr" example:"938503154"` // The Group number Group int `json:"group" example:"1"` // The StartingAddresses of the teacher StartingAddresses []string `json:"starting_addresses" example:"Zuhause 1,Zuhause 2"` // The TripGoals the teacher visited before TripGoals []string `json:"trip_goals" example:"Karl Hönck Heim,PH Wien,Landesgericht St. Pölten"` // The Departments this teacher belongs to Departments []string `json:"departments" example:"HIT,HBG"` // The Untis abbrevation of the teacher Untis string `json:"untis" example:"ZAKS"` }
TeacherInformation contains changeable information of the teacher
type Token ¶
type Token struct { // AccessToken is the access token itself AccessToken string // RefreshToken is the refresh token itself RefreshToken string // AccessUUID is the uuid the access token is referenced by AccessUUID string // RefreshUUID is the uuid the refresh token is referenced by RefreshUUID string // AccessExpires is the date the access tokens expires at AccessExpires int64 // RefreshExpires is the date the refresh tokens expires at RefreshExpires int64 }
Token represents a token pair
func CreateToken ¶
CreateToken creates a token pair based on a username