Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Container 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
hdacloud
dex
Commits
74b44e97
"routingtable/git@code.fbi.h-da.de:danet/bio-rd.git" did not exist on "d5767c9eeb6f157ee79e1635e5958be6e2bf108a"
Commit
74b44e97
authored
8 years ago
by
Eric Chiang
Browse files
Options
Downloads
Patches
Plain Diff
storage: add a password resource
parent
c50b44cf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/storage.go
+31
-5
31 additions, 5 deletions
storage/storage.go
with
31 additions
and
5 deletions
storage/storage.go
+
31
−
5
View file @
74b44e97
...
@@ -16,12 +16,12 @@ import (
...
@@ -16,12 +16,12 @@ import (
)
)
var
(
var
(
// stubbed out for testing
// ErrNotFound is the error returned by storages if a resource cannot be found.
now
=
time
.
Now
ErrNotFound
=
errors
.
New
(
"not found"
)
)
// ErrNotFound is the error returned by storages if a resource cannot be found.
// ErrAlreadyExists is the error returned by storages if a resource ID is taken during a create.
var
ErrNotFound
=
errors
.
New
(
"not found"
)
ErrAlreadyExists
=
errors
.
New
(
"ID already exists"
)
)
// Kubernetes only allows lower case letters for names.
// Kubernetes only allows lower case letters for names.
//
//
...
@@ -51,6 +51,7 @@ type Storage interface {
...
@@ -51,6 +51,7 @@ type Storage interface {
CreateClient
(
c
Client
)
error
CreateClient
(
c
Client
)
error
CreateAuthCode
(
c
AuthCode
)
error
CreateAuthCode
(
c
AuthCode
)
error
CreateRefresh
(
r
RefreshToken
)
error
CreateRefresh
(
r
RefreshToken
)
error
CreatePassword
(
p
Password
)
error
// TODO(ericchiang): return (T, bool, error) so we can indicate not found
// TODO(ericchiang): return (T, bool, error) so we can indicate not found
// requests that way instead of using ErrNotFound.
// requests that way instead of using ErrNotFound.
...
@@ -59,6 +60,7 @@ type Storage interface {
...
@@ -59,6 +60,7 @@ type Storage interface {
GetClient
(
id
string
)
(
Client
,
error
)
GetClient
(
id
string
)
(
Client
,
error
)
GetKeys
()
(
Keys
,
error
)
GetKeys
()
(
Keys
,
error
)
GetRefresh
(
id
string
)
(
RefreshToken
,
error
)
GetRefresh
(
id
string
)
(
RefreshToken
,
error
)
GetPassword
(
email
string
)
(
Password
,
error
)
ListClients
()
([]
Client
,
error
)
ListClients
()
([]
Client
,
error
)
ListRefreshTokens
()
([]
RefreshToken
,
error
)
ListRefreshTokens
()
([]
RefreshToken
,
error
)
...
@@ -68,6 +70,7 @@ type Storage interface {
...
@@ -68,6 +70,7 @@ type Storage interface {
DeleteAuthCode
(
code
string
)
error
DeleteAuthCode
(
code
string
)
error
DeleteClient
(
id
string
)
error
DeleteClient
(
id
string
)
error
DeleteRefresh
(
id
string
)
error
DeleteRefresh
(
id
string
)
error
DeletePassword
(
email
string
)
error
// Update functions are assumed to be a performed within a single object transaction.
// Update functions are assumed to be a performed within a single object transaction.
//
//
...
@@ -75,6 +78,7 @@ type Storage interface {
...
@@ -75,6 +78,7 @@ type Storage interface {
UpdateClient
(
id
string
,
updater
func
(
old
Client
)
(
Client
,
error
))
error
UpdateClient
(
id
string
,
updater
func
(
old
Client
)
(
Client
,
error
))
error
UpdateKeys
(
updater
func
(
old
Keys
)
(
Keys
,
error
))
error
UpdateKeys
(
updater
func
(
old
Keys
)
(
Keys
,
error
))
error
UpdateAuthRequest
(
id
string
,
updater
func
(
a
AuthRequest
)
(
AuthRequest
,
error
))
error
UpdateAuthRequest
(
id
string
,
updater
func
(
a
AuthRequest
)
(
AuthRequest
,
error
))
error
UpdatePassword
(
email
string
,
updater
func
(
p
Password
)
(
Password
,
error
))
error
// TODO(ericchiang): Add a GarbageCollect(now time.Time) method so conformance tests
// TODO(ericchiang): Add a GarbageCollect(now time.Time) method so conformance tests
// can test implementations.
// can test implementations.
...
@@ -217,6 +221,28 @@ type RefreshToken struct {
...
@@ -217,6 +221,28 @@ type RefreshToken struct {
Nonce
string
Nonce
string
}
}
// Password is an email to password mapping managed by the storage.
type
Password
struct
{
// Email and identifying name of the password. Emails are assumed to be valid and
// determining that an end-user controls the address is left to an outside application.
//
// Emails are case insensitive and should be standardized by the storage.
//
// Storages that don't support an extended character set for IDs, such as '.' and '@'
// (cough cough, kubernetes), must map this value appropriately.
Email
string
`yaml:"email"`
// Bcrypt encoded hash of the password. This package recommends a cost value of at
// least 14.
Hash
[]
byte
`yaml:"hash"`
// Optional username to display. NOT used during login.
Username
string
`yaml:"username"`
// Randomly generated user ID. This is NOT the primary ID of the Password object.
UserID
string
`yaml:"userID"`
}
// VerificationKey is a rotated signing key which can still be used to verify
// VerificationKey is a rotated signing key which can still be used to verify
// signatures.
// signatures.
type
VerificationKey
struct
{
type
VerificationKey
struct
{
...
...
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