-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Keycloak role permissions system
- Loading branch information
1 parent
6587754
commit a29d9eb
Showing
3 changed files
with
42 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
package models | ||
|
||
import ( | ||
"database/sql/driver" | ||
"encoding/json" | ||
"errors" | ||
) | ||
|
||
type Oauth2Token struct { | ||
UserID string `json:"user_id"` | ||
TokenType string `json:"token_type"` | ||
AccessToken string `json:"access_token"` | ||
RefreshToken string `json:"refresh_token"` | ||
ExpiresIn int `json:"expires_in"` | ||
RefreshExpiresIn int `json:"refresh_expires_in"` | ||
UserID string `json:"user_id"` | ||
TokenType string `json:"token_type"` | ||
AccessToken string `json:"access_token"` | ||
RefreshToken string `json:"refresh_token"` | ||
ExpiresIn int `json:"expires_in"` | ||
RefreshExpiresIn int `json:"refresh_expires_in"` | ||
Permissions StrArray `json:"permissions" gorm:"type:jsonb;index,type:gin"` | ||
} | ||
|
||
func (Oauth2Token) TableName() string { | ||
return "oauth2_tokens" | ||
} | ||
|
||
type StrArray []string | ||
|
||
// Value Marshal | ||
func (a StrArray) Value() (driver.Value, error) { | ||
return json.Marshal(a) | ||
} | ||
|
||
// Scan Unmarshal | ||
func (a *StrArray) Scan(value interface{}) error { | ||
b, ok := value.([]byte) | ||
if !ok { | ||
return errors.New("type assertion to []byte failed") | ||
} | ||
return json.Unmarshal(b, &a) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters