-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
aeneasr
committed
Mar 21, 2016
1 parent
eb9153c
commit ba84987
Showing
89 changed files
with
1,462 additions
and
631 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
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,25 +1,38 @@ | ||
package fosite | ||
|
||
import ( | ||
"time" | ||
) | ||
import "time" | ||
|
||
type AccessRequest struct { | ||
GrantType string | ||
HandledGrantType []string | ||
GrantTypes Arguments | ||
HandledGrantType Arguments | ||
RequestedAt time.Time | ||
|
||
Request | ||
} | ||
|
||
func (a *AccessRequest) DidHandleGrantType() bool { | ||
return StringInSlice(a.GrantType, a.HandledGrantType) | ||
func NewAccessRequest(session interface{}) *AccessRequest { | ||
return &AccessRequest{ | ||
Request: Request{ | ||
Scopes: Arguments{}, | ||
Session: session, | ||
RequestedAt: time.Now(), | ||
}, | ||
} | ||
} | ||
|
||
func (a *AccessRequest) DidHandleGrantTypes() bool { | ||
for _, grantType := range a.GrantTypes { | ||
if !StringInSlice(grantType, a.HandledGrantType) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
func (a *AccessRequest) SetGrantTypeHandled(name string) { | ||
a.HandledGrantType = append(a.HandledGrantType, name) | ||
} | ||
|
||
func (a *AccessRequest) GetGrantType() string { | ||
return a.GrantType | ||
func (a *AccessRequest) GetGrantTypes() Arguments { | ||
return a.GrantTypes | ||
} |
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
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,18 +1,19 @@ | ||
package fosite | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ory-am/fosite/client" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestAccessRequest(t *testing.T) { | ||
ar := &AccessRequest{} | ||
ar.GrantType = "foobar" | ||
ar.GrantTypes = Arguments{"foobar"} | ||
ar.Client = &client.SecureClient{} | ||
ar.GrantScope("foo") | ||
assert.True(t, ar.GetGrantedScopes().Has("foo")) | ||
assert.NotNil(t, ar.GetRequestedAt()) | ||
assert.Equal(t, ar.GrantType, ar.GetGrantType()) | ||
assert.Equal(t, ar.GrantTypes, ar.GetGrantTypes()) | ||
assert.Equal(t, ar.Client, ar.GetClient()) | ||
} |
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
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
Oops, something went wrong.