327 lines
7.1 KiB
JavaScript
327 lines
7.1 KiB
JavaScript
import { gql } from 'apollo-server'
|
|
|
|
const typeDefs = gql`
|
|
type Query {
|
|
"Returns only a few fields of a user"
|
|
basicUser(sAMAccountName: String!): User! @cacheControl(maxAge: 10)
|
|
|
|
"The authenticated user"
|
|
me: User! @auth
|
|
|
|
"All users matching the criteria"
|
|
users(
|
|
where: UserWhereInput!
|
|
"How many?"
|
|
limit: Int = 15
|
|
"Should return only students?"
|
|
onlyStudents: Boolean = false
|
|
): [User!] @auth(roles: ["servant"]) @cacheControl(maxAge: 10)
|
|
|
|
"A single user"
|
|
user(sAMAccountName: String!): User!
|
|
@auth(roles: ["superAdmin"])
|
|
@cacheControl(maxAge: 10)
|
|
|
|
"AD groups"
|
|
groups(where: GroupWhereInput!, limit: Int = 10): [Group!]!
|
|
@auth(roles: ["servant"])
|
|
@cacheControl(maxAge: 10)
|
|
|
|
"Current stats. Differs from the historical statistics."
|
|
stats: Stats!
|
|
|
|
"Users who has some device currently connected to Wi-Fi"
|
|
userPresence(search: String = ""): [UserPresence!] @auth(roles: ["watcher"])
|
|
|
|
"Devices that uses the Wi-Fi"
|
|
wifiDevices(
|
|
search: String = ""
|
|
identifiedOnly: Boolean = false
|
|
nonIdentifiedOnly: Boolean = false
|
|
): [WifiDevice]! @auth(roles: ["superAdmin"])
|
|
|
|
"Users that uses the Wi-Fi"
|
|
wifiUsers: [User]! @auth(roles: ["superAdmin"])
|
|
|
|
"Application Logs"
|
|
logs(
|
|
search: String = ""
|
|
dateIn: String
|
|
dateOut: String
|
|
limit: Int = 200
|
|
): [Log]! @auth(roles: ["superAdmin"])
|
|
|
|
pAHosts: [PAHost!]! @auth(roles: ["superAdmin"])
|
|
}
|
|
|
|
type Mutation {
|
|
"System login"
|
|
login(data: LoginInput!): AuthPayload!
|
|
|
|
"Update own password"
|
|
updatePassword(data: UpdatePasswordInput!): AuthPayload! @auth
|
|
|
|
"Update someone elses password"
|
|
replacePassword(data: ReplacePasswordInput!): String!
|
|
@auth(roles: ["superAdmin"])
|
|
|
|
"Create a Reset Token to reset a student password"
|
|
createResetToken(data: CreateResetTokenInput!): ResetToken!
|
|
@auth(roles: ["superAdmin", "tokenCreator"])
|
|
|
|
"Use a provided Reset Token to update a user password"
|
|
useResetToken(data: UseResetTokenInput!): Boolean!
|
|
|
|
"Delete all expired Tokens"
|
|
deleteExpiredTokens: String!
|
|
|
|
"Import all users from Active Directory"
|
|
importUsers: String! @auth(roles: ["superAdmin"])
|
|
|
|
"Force update devices connected to Wi-Fi"
|
|
updateWifiDevices: String! @auth(roles: ["superAdmin"])
|
|
|
|
"Force update user-id mapping on firewall"
|
|
updateUserIdMappings: String! @auth(roles: ["superAdmin"])
|
|
|
|
"Add a PA host"
|
|
addPAHost(data: AddPAHostInput!): PAHost! @auth(roles: ["superAdmin"])
|
|
|
|
"Remove a PA host"
|
|
delPAHost(id: Int!): PAHost! @auth(roles: ["superAdmin"])
|
|
}
|
|
|
|
type Subscription {
|
|
"The information about users who has some device currently connected to Wi-Fi was updated"
|
|
userPresenceUpdated: Int! @auth(roles: ["watcher"])
|
|
|
|
"Info about the logged user was updated"
|
|
authUpdated: User! @auth
|
|
}
|
|
|
|
"Needs authentication. Optionally, provide an array with roles to match."
|
|
directive @auth(roles: [String!]) on FIELD_DEFINITION
|
|
|
|
"A mix between the database User and the Active Directory User"
|
|
type User {
|
|
id: ID
|
|
wifiDevices: [WifiDevice!]
|
|
lastLogin: String
|
|
lastLoginPrior: String
|
|
roles: [String!]
|
|
groups: [Group!]
|
|
sharedFolders: [String!]
|
|
sharedPrinters: [String!]
|
|
|
|
firstName: String
|
|
|
|
isSuperAdmin: Boolean!
|
|
isTokenCreator: Boolean!
|
|
isServant: Boolean!
|
|
isStudent: Boolean!
|
|
isWatcher: Boolean!
|
|
|
|
createdAt: String!
|
|
updatedAt: String!
|
|
|
|
accountExpires: String
|
|
badPasswordTime: String
|
|
badPwdCount: String
|
|
cn: String
|
|
department: String
|
|
description: String
|
|
displayName: String
|
|
distinguishedName: String
|
|
dn: String
|
|
extensionAttribute1: String
|
|
extensionAttribute10: String
|
|
extensionAttribute2: String
|
|
extensionAttribute6: String
|
|
extensionAttribute7: String
|
|
givenName: String
|
|
homeDirectory: String
|
|
homeDrive: String
|
|
lastLogon: String
|
|
lastLogonTimestamp: String
|
|
lockoutTime: String
|
|
logonCount: String
|
|
mail: String
|
|
name: String
|
|
objectCategory: String
|
|
objectGUID: String
|
|
objectSid: String
|
|
primaryGroupID: String
|
|
pwdLastSet: String
|
|
sAMAccountName: String!
|
|
sAMAccountType: String
|
|
sn: String
|
|
thumbnailPhoto: String
|
|
title: String
|
|
userAccountControl: String
|
|
userPrincipalName: String
|
|
whenChanged: String
|
|
whenCreated: String
|
|
}
|
|
|
|
"Active Directory Groups"
|
|
type Group {
|
|
cn: String!
|
|
dn: String!
|
|
name: String
|
|
members: [User!]!
|
|
}
|
|
|
|
"Authentication payload"
|
|
type AuthPayload {
|
|
"The user who has logged in"
|
|
user: User!
|
|
"A Json Web Token used to authenticate with the API"
|
|
token: String!
|
|
"Time to invalidate the provided token"
|
|
expiresIn: String!
|
|
}
|
|
|
|
"A token to be used for passwords updates"
|
|
type ResetToken {
|
|
id: ID!
|
|
user: User!
|
|
creator: User!
|
|
token: String!
|
|
expiration: String!
|
|
|
|
createdAt: String!
|
|
updatedAt: String!
|
|
}
|
|
|
|
"Current stats"
|
|
type Stats {
|
|
tokenCountTotal: Int!
|
|
tokenCountUsed: Int!
|
|
tokenCountExpired: Int!
|
|
tokenCountNotUsed: Int!
|
|
onlineUsers: Int!
|
|
offlineUsers: Int!
|
|
totalUsers: Int!
|
|
totalWifiDevices: Int!
|
|
onlineWifiDevices: Int!
|
|
}
|
|
|
|
"A device connected to the Wi-Fi"
|
|
type WifiDevice {
|
|
user: User
|
|
id: ID!
|
|
oui: String
|
|
mac: String!
|
|
controller: String!
|
|
hostname: String
|
|
firstSeen: String
|
|
lastSeen: String
|
|
essid: String
|
|
ip: String
|
|
uptime: String
|
|
apName: String
|
|
status: Status
|
|
}
|
|
|
|
"A user that is on the Wi-Fi network reach"
|
|
type UserPresence {
|
|
id: ID!
|
|
displayName: String!
|
|
thumbnailPhoto: String
|
|
lastSeen: String!
|
|
status: Status!
|
|
apName: String!
|
|
}
|
|
|
|
"The status of a Device"
|
|
enum Status {
|
|
ONLINE
|
|
RECENT
|
|
OFFLINE
|
|
}
|
|
|
|
"A log message"
|
|
type Log {
|
|
id: ID!
|
|
timestamp: String!
|
|
level: LogLevel!
|
|
tags: [String]!
|
|
message: String
|
|
data: String
|
|
}
|
|
|
|
"The severity of a log entry"
|
|
enum LogLevel {
|
|
LOW
|
|
INFO
|
|
SUCCESS
|
|
WARNING
|
|
ERROR
|
|
}
|
|
|
|
"A Palo Alto firewall host"
|
|
type PAHost {
|
|
id: ID!
|
|
"Short description"
|
|
description: String!
|
|
"IP address in CIDR format"
|
|
cidr: String!
|
|
"First 5 characters from the key"
|
|
key: String!
|
|
"OptionalNote"
|
|
note: String
|
|
"The API key owner"
|
|
user: String
|
|
"The user who added the host"
|
|
owner: User!
|
|
|
|
createdAt: String
|
|
updatedAt: String
|
|
}
|
|
|
|
input LoginInput {
|
|
username: String!
|
|
password: String!
|
|
}
|
|
input UpdatePasswordInput {
|
|
oldPassword: String!
|
|
newPassword: String!
|
|
}
|
|
|
|
input ReplacePasswordInput {
|
|
username: String!
|
|
newPassword: String!
|
|
}
|
|
|
|
input UserWhereInput {
|
|
cn: String
|
|
displayName: String
|
|
sAMAccountName: String
|
|
}
|
|
|
|
input GroupWhereInput {
|
|
cn: String
|
|
dn: String
|
|
name: String
|
|
}
|
|
|
|
input CreateResetTokenInput {
|
|
username: String!
|
|
}
|
|
|
|
input UseResetTokenInput {
|
|
token: String!
|
|
newPassword: String!
|
|
}
|
|
|
|
input AddPAHostInput {
|
|
cidr: String!
|
|
user: String!
|
|
password: String!
|
|
description: String!
|
|
note: String
|
|
}
|
|
`
|
|
|
|
export { typeDefs }
|