mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05:28 +02:00
auth with cas
This commit is contained in:
parent
8c99977fc9
commit
8c2df6178d
150 changed files with 43682 additions and 24175 deletions
60
vendor/gopkg.in/cas.v2/memory_store.go
generated
vendored
Normal file
60
vendor/gopkg.in/cas.v2/memory_store.go
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
package cas
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// MemoryStore implements the TicketStore interface storing ticket data in memory.
|
||||
type MemoryStore struct {
|
||||
mu sync.RWMutex
|
||||
store map[string]*AuthenticationResponse
|
||||
}
|
||||
|
||||
// Read returns the AuthenticationResponse for a ticket
|
||||
func (s *MemoryStore) Read(id string) (*AuthenticationResponse, error) {
|
||||
s.mu.RLock()
|
||||
|
||||
if s.store == nil {
|
||||
s.mu.RUnlock()
|
||||
return nil, ErrInvalidTicket
|
||||
}
|
||||
|
||||
t, ok := s.store[id]
|
||||
s.mu.RUnlock()
|
||||
|
||||
if !ok {
|
||||
return nil, ErrInvalidTicket
|
||||
}
|
||||
|
||||
return t, nil
|
||||
}
|
||||
|
||||
// Write stores the AuthenticationResponse for a ticket
|
||||
func (s *MemoryStore) Write(id string, ticket *AuthenticationResponse) error {
|
||||
s.mu.Lock()
|
||||
|
||||
if s.store == nil {
|
||||
s.store = make(map[string]*AuthenticationResponse)
|
||||
}
|
||||
|
||||
s.store[id] = ticket
|
||||
|
||||
s.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete removes the AuthenticationResponse for a ticket
|
||||
func (s *MemoryStore) Delete(id string) error {
|
||||
s.mu.Lock()
|
||||
delete(s.store, id)
|
||||
s.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clear removes all ticket data
|
||||
func (s *MemoryStore) Clear() error {
|
||||
s.mu.Lock()
|
||||
s.store = nil
|
||||
s.mu.Unlock()
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue