Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLOUDTRUST-1157] Add user_id in events + allow generic HTTP reponse #15

Merged
merged 6 commits into from Jun 5, 2019

Conversation

fperot74
Copy link
Contributor

@fperot74 fperot74 commented Jun 3, 2019

Generic response let REST methods be able to choose a status code, set headers, return mime content, ...

@fperot74 fperot74 requested review from harture and bsoniam June 3, 2019 09:02
@coveralls
Copy link

coveralls commented Jun 3, 2019

Coverage Status

Coverage increased (+0.9%) to 90.948% when pulling 73ec38f on location into f11f8c8 on master.

@fperot74 fperot74 changed the title Allow API methods be able to respond with a generic reponse Allow generic HTTP reponse + Events enhancements Jun 4, 2019

//store the event in the DB
_, err := cm.db.Exec(insertEvent, auditTime, origin, realmName, agentUserID, agentUsername, agentRealmName, userID, username, ctEventType, kcEventType, kcOperationType, clientID, additionalInfo)
_, err := cm.db.Exec(insertEvent, auditTime, origin, checkNull(realmName), checkNull(agentUserID), checkNull(agentUsername),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to check for empty string ?

Copy link
Contributor Author

@fperot74 fperot74 Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have NULL in database rather than empty string. NULL is easier to manage when searching for events

Copy link
Contributor

@harture harture left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some points needs to be discussed before merge

additionalInfo := m["additional_info"]
additionalInfo := m[CtEventAdditionalInfo]
if additionalInfo == "" {
var addNfo = make(map[string]string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nfo ? is it a typo for Info ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I often write Nfo for information... or Info... yes, I'm a little bit lazy

//additional_info - all the rest of the information from the event
additionalInfo := m["additional_info"]
additionalInfo := m[CtEventAdditionalInfo]
if additionalInfo == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do it only if additionalInfo is empty but I think we should do it anyway.
Initially Sonia did it somewhere else, is it moved here ? or done twice ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done by Sonia in the bridge... This way, it remains compatible with her version and new developments but you have to choose to set additional_info by your self OR let this function set it

http/handlers.go Outdated
StatusCode int
Headers map[string]string
MimeContent *MimeContent
ExportToJSON interface{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we a type more restrictive than interface{} here ? It seems error prone and it would help to understand what it does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed together, renamed to JSONableResponse

if err == nil {
w.Write(json)
switch e := rep.(type) {
case GenericResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenericResponse is HTTP oriented.
The intial purpose was to split it between an answer that can be translated into a specific kind of response, HTTP or gRPC, ... I know that we don't have it anymore but I think it was a good split of concerns.

@fperot74 fperot74 changed the title Allow generic HTTP reponse + Events enhancements [CLOUDTRUST-1157] Allow generic HTTP reponse + Events enhancements Jun 5, 2019
@fperot74 fperot74 changed the title [CLOUDTRUST-1157] Allow generic HTTP reponse + Events enhancements [CLOUDTRUST-1157] Add user_id in events + allow generic HTTP reponse Jun 5, 2019
@harture harture self-requested a review June 5, 2019 07:43
@fperot74 fperot74 merged commit cdc73eb into master Jun 5, 2019
@fperot74 fperot74 deleted the location branch June 5, 2019 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants