Commit 6b16c88f25f9cb688e9f9f1fcf132e446fd3ab86
1 parent
b0a6d6322d
Exists in
master
and in
1 other branch
Working version with ora v4
Showing
2 changed files
with
8 additions
and
2 deletions
Show diff stats
auth_utility.go
... | ... | @@ -22,11 +22,16 @@ const RoleAdmin string = "ADMINISTRATOR" |
22 | 22 | const RoleManager string = "RUKOVODILAC" |
23 | 23 | const RoleReporter string = "REPORTER" |
24 | 24 | const RoleOperator string = "OPERATER" |
25 | +const RoleAdminID uint32 = 1 | |
26 | +const RoleManagerID uint32 = 2 | |
27 | +const RoleReporterID uint32 = 3 | |
28 | +const RoleOperatorID uint32 = 4 | |
25 | 29 | |
26 | 30 | // TokenClaims are JWT token claims. |
27 | 31 | type TokenClaims struct { |
28 | 32 | Username string `json:"username"` |
29 | 33 | Role string `json:"role"` |
34 | + RoleID uint32 `json:"roleID"` | |
30 | 35 | jwt.StandardClaims |
31 | 36 | } |
32 | 37 | |
... | ... | @@ -85,7 +90,7 @@ func HashString(str string, presalt string) (hash, salt string, err error) { |
85 | 90 | |
86 | 91 | // CreateAPIToken returns JWT token with encoded username, role, expiration date and issuer claims. |
87 | 92 | // It returns an error if it fails. |
88 | -func CreateAPIToken(username, role string) (string, error) { | |
93 | +func CreateAPIToken(username, role string, roleID uint32) (string, error) { | |
89 | 94 | var apiToken string |
90 | 95 | var err error |
91 | 96 | |
... | ... | @@ -96,6 +101,7 @@ func CreateAPIToken(username, role string) (string, error) { |
96 | 101 | claims := TokenClaims{ |
97 | 102 | username, |
98 | 103 | role, |
104 | + roleID, | |
99 | 105 | jwt.StandardClaims{ |
100 | 106 | ExpiresAt: (time.Now().Add(OneWeek)).Unix(), |
101 | 107 | Issuer: appName, | ... | ... |
json_utility.go
... | ... | @@ -161,7 +161,7 @@ func InitTables(db *ora.Ses, project string) error { |
161 | 161 | // Returns an error if it fails. |
162 | 162 | func fetchJSON(db *ora.Ses, project string) ([]byte, error) { |
163 | 163 | db.SetCfg(db.Cfg().SetClob(ora.S)) |
164 | - stmt, err := db.Prep(`SELECT JSON_CLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S) | |
164 | + stmt, err := db.Prep(`SELECT JSON_NCLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S) | |
165 | 165 | defer stmt.Close() |
166 | 166 | if err != nil { |
167 | 167 | return nil, err | ... | ... |