Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DCSG2900-ThreatTotal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Barstad
DCSG2900-ThreatTotal
Commits
ab254c38
Commit
ab254c38
authored
3 years ago
by
Jonas Kjærandsen
Browse files
Options
Downloads
Patches
Plain Diff
Added more comments to auth.go
parent
2fc8cf74
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
auth/auth.go
+2
-28
2 additions, 28 deletions
auth/auth.go
with
2 additions
and
28 deletions
auth/auth.go
+
2
−
28
View file @
ab254c38
...
@@ -97,29 +97,7 @@ func CodeToToken(code string) (token string, authenticated bool) {
...
@@ -97,29 +97,7 @@ func CodeToToken(code string) (token string, authenticated bool) {
logging
.
Logerror
(
err
,
"Error adding data to redis Auth.go:"
)
logging
.
Logerror
(
err
,
"Error adding data to redis Auth.go:"
)
return
""
,
false
return
""
,
false
}
}
//fmt.Println(response)
// Uses the old token to get the userinfo again if expired
/*
userInfo, err := utils.Provider.UserInfo(utils.Ctx, oauth2.StaticTokenSource(oauth2Token))
if err != nil {
fmt.Println("Failed to get userinfo: " + err.Error())
return "", false
}
// Still need a function to check expiration of the access-token somehow
fmt.Println(oauth2.StaticTokenSource(oauth2Token).Token())
fmt.Println(userInfo)
*/
//
// Make the token a FeideToken struct
// Return it
// If everything is successfull return true and the authentication code for the frontend user.
return
hash
,
true
return
hash
,
true
}
}
...
@@ -152,16 +130,11 @@ func getAuth(hash string) (token string, err bool) {
...
@@ -152,16 +130,11 @@ func getAuth(hash string) (token string, err bool) {
return
""
,
false
return
""
,
false
}
}
//fmt.Println("marhaslled data: ", responseData)
// If email is needed a helper which checks the expiration of the jwt
// and requests a new one is needed.
return
responseData
.
Oauth2Token
.
AccessToken
,
true
return
responseData
.
Oauth2Token
.
AccessToken
,
true
}
}
}
}
// Func which takes an authentication token and returns a
ha
sh.
// Func which takes an authentication token and returns a sh
a256 hash of it
.
func
tokenToHash
(
code
string
)
(
hash
string
)
{
func
tokenToHash
(
code
string
)
(
hash
string
)
{
// Create the sha256 hash
// Create the sha256 hash
fileHash
:=
sha256
.
New
()
fileHash
:=
sha256
.
New
()
...
@@ -170,6 +143,7 @@ func tokenToHash(code string) (hash string) {
...
@@ -170,6 +143,7 @@ func tokenToHash(code string) (hash string) {
return
fmt
.
Sprintf
(
"%x"
,
fileHash
.
Sum
(
nil
))
return
fmt
.
Sprintf
(
"%x"
,
fileHash
.
Sum
(
nil
))
}
}
// Functtion which takes a user and deletes it from the backend, for log out purposes.
func
Logout
(
hash
string
)
bool
{
func
Logout
(
hash
string
)
bool
{
// Delete the database item
// Delete the database item
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment