forked from choria-io/aaasvc
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
800b8cb
commit 318fb82
Showing
14 changed files
with
444 additions
and
21 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package remoteuser | ||
|
||
import ( | ||
"io/ioutil" | ||
"sync" | ||
) | ||
|
||
// DefaulUser is a choria user without user and/or password | ||
type DefaultUser struct { | ||
// Organization is a org name the user belongs to | ||
Organization string `json:"organization"` | ||
|
||
// ACLs are for the action list authorizer | ||
ACLs []string `json:"acls"` | ||
|
||
// OPAPolicy is a string holding a Open Policy Agent rego policy | ||
OPAPolicy string `json:"opa_policy"` | ||
|
||
// OPAPolicyFile is the path to a rego file to embed as the policy for this user | ||
OPAPolicyFile string `json:"opa_policy_file"` | ||
|
||
// Properties are free form additional information to add about a user, this can be | ||
// referenced later in an authorizer like the Open Policy one | ||
Properties map[string]string `json:"properties"` | ||
|
||
sync.Mutex | ||
} | ||
|
||
// OpenPolicy retrieves the OPA Policy either from `OPAPolicy` or by reading the file in `OPAPolicyFile` | ||
func (u DefaultUser) OpenPolicy() (policy string, err error) { | ||
u.Lock() | ||
defer u.Unlock() | ||
|
||
if u.OPAPolicy != "" { | ||
return u.OPAPolicy, nil | ||
} | ||
|
||
if u.OPAPolicyFile == "" { | ||
return "", nil | ||
} | ||
|
||
out, err := ioutil.ReadFile(u.OPAPolicyFile) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return string(out), nil | ||
} |
Oops, something went wrong.