Basic database structure and partial implementation for UACs and tokens

This commit is contained in:
digimint 2024-06-24 03:41:00 -05:00
parent 9c6a1e808f
commit 36afeaad42
Signed by: digimint
GPG key ID: 947E0031C671B9A0
13 changed files with 454 additions and 192 deletions

View file

@ -1,36 +1,36 @@
/*
UNIT_CA5 - Stream management bot
Copyright (C) 2024 digimint
UNIT_CA5 - Stream management bot
Copyright (C) 2024 digimint
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package unit_ca5.twitch
package twitch.api
import java.time.Instant
import unit_ca5.twitch.TokenScope
import twitch.api.TokenScope
type TwitchUID = String
type AccessToken = String
type RefreshToken = String
case class UserAuthenticationCredential(
userId: TwitchUID,
accessToken: AccessToken,
refreshToken: RefreshToken,
expires: Instant,
scopes: List[TokenScope]
userId : TwitchUID,
accessToken : AccessToken,
refreshToken : RefreshToken,
expires : Instant,
scopes : List[TokenScope]
):
def is_expired(now: Instant): Boolean =
now.isAfter(expires)
@ -39,4 +39,6 @@ case class UserAuthenticationCredential(
scopes.contains(scope)
def supportsAll(scopeList: List[TokenScope]): Boolean =
scopeList.forall(
scopes.contains
)