summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v5/model/access.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-08-05 20:43:19 +0200
committerGitHub <noreply@github.com>2023-08-05 20:43:19 +0200
commit56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (patch)
treeb1355645342667209263cbd355dc0b4254f1e8fe /vendor/github.com/mattermost/mattermost-server/v5/model/access.go
parent9459495484d6e06a3d46de64fccd8d06f7ccc72c (diff)
downloadmatterbridge-msglm-master.tar.gz
matterbridge-msglm-master.tar.bz2
matterbridge-msglm-master.zip
Update dependencies and remove old matterclient lib (#2067)HEADmaster
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v5/model/access.go')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/model/access.go97
1 files changed, 0 insertions, 97 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/model/access.go b/vendor/github.com/mattermost/mattermost-server/v5/model/access.go
deleted file mode 100644
index 6b60ea9e..00000000
--- a/vendor/github.com/mattermost/mattermost-server/v5/model/access.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See LICENSE.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
-)
-
-const (
- ACCESS_TOKEN_GRANT_TYPE = "authorization_code"
- ACCESS_TOKEN_TYPE = "bearer"
- REFRESH_TOKEN_GRANT_TYPE = "refresh_token"
-)
-
-type AccessData struct {
- ClientId string `json:"client_id"`
- UserId string `json:"user_id"`
- Token string `json:"token"`
- RefreshToken string `json:"refresh_token"`
- RedirectUri string `json:"redirect_uri"`
- ExpiresAt int64 `json:"expires_at"`
- Scope string `json:"scope"`
-}
-
-type AccessResponse struct {
- AccessToken string `json:"access_token"`
- TokenType string `json:"token_type"`
- ExpiresIn int32 `json:"expires_in"`
- Scope string `json:"scope"`
- RefreshToken string `json:"refresh_token"`
- IdToken string `json:"id_token"`
-}
-
-// IsValid validates the AccessData and returns an error if it isn't configured
-// correctly.
-func (ad *AccessData) IsValid() *AppError {
-
- if ad.ClientId == "" || len(ad.ClientId) > 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if ad.UserId == "" || len(ad.UserId) > 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.Token) != 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.access_token.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.RefreshToken) > 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.refresh_token.app_error", nil, "", http.StatusBadRequest)
- }
-
- if ad.RedirectUri == "" || len(ad.RedirectUri) > 256 || !IsValidHttpUrl(ad.RedirectUri) {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.redirect_uri.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (ad *AccessData) IsExpired() bool {
-
- if ad.ExpiresAt <= 0 {
- return false
- }
-
- if GetMillis() > ad.ExpiresAt {
- return true
- }
-
- return false
-}
-
-func (ad *AccessData) ToJson() string {
- b, _ := json.Marshal(ad)
- return string(b)
-}
-
-func AccessDataFromJson(data io.Reader) *AccessData {
- var ad *AccessData
- json.NewDecoder(data).Decode(&ad)
- return ad
-}
-
-func (ar *AccessResponse) ToJson() string {
- b, _ := json.Marshal(ar)
- return string(b)
-}
-
-func AccessResponseFromJson(data io.Reader) *AccessResponse {
- var ar *AccessResponse
- json.NewDecoder(data).Decode(&ar)
- return ar
-}