Surreal DB - Sign up doesn't validate if user already exists and sign in works with any random credentials? - surrealdb

I have created a scope as follows:
CURL POST /sql:
DEFINE SCOPE user SESSION 1d
SIGNUP ( CREATE user SET user = $user, pass = crypto::argon2::generate($pass) )
SIGNIN ( SELECT * FROM user WHERE user = $user AND crypto::argon2::compare(pass, $pass));
then I Signed up as following:
{
"ns": "test",
"db": "test",
"sc": "user",
"email": "tobie#surrealdb.com",
"pass": "some password",
"marketing": true,
"tags": [
"rust",
"golang",
"javascript"
]
}
Here I recieve:
{
"code": 200,
"details": "Authentication succeeded",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOEQiI6InRlc3QiLCJTQyI6InVzZXIiLCJJRCI6InVzZXI6czFiN3JzcnlxNW9jdDVmM2FrdHEifQ.oy7ox2QCqNDAyZnvRmGPoU2t3QmzB38J67ynpRVPfd8nXfRw0RQPunQ04KTrtzfQeNHB5Zv8-nN0HrOuqxG78w"
}
After which i try to sign in:
{
"ns": "test",
"db": "test",
"sc": "user",
"email": "tobie#surrealdb.com",
"pass": "some password"
}
which succeeds:
{
"code": 200,
"details": "Authentication succeeded",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NzIwMzc4NTAsIm5iZiI6MTY3MjAzNzg1MCwiZXhwIjoxNjcyMTI0MjUwLCJpY-l8cGbHeW72CbBIswIro-Tlan-QZuJFHVTIhUCP-1k1m-z8-YM7JYbXWT9IgPskKgzRDCJSt6iXmV-jw"
}
however when I do:
{
"ns": "test",
"db": "test",
"sc": "user",
"email": "tobiedsfds2#surrealdb.com",
"pass": "some password"
}
As you can see I added some random characters in email which is not signed up still I get a 200 response. And similarly when I try to sign up with a duplicate email, that succeeds too.
Any explanation that could possibly help to understand what's happening here?

Related

I am using rocket chat websocket. In those messages when we get the message of "user added" or "removed" I want the user's full name

wss://[ABC.DOMAIN.COM]/websocket
I am using websocket of rocket chat.
This is one of the message from the list of messages response the websocket provides.
{
"_id": "some id",
"t": "au",
"rid": "some id",
"ts": {
"$date": 1663823165892
},
"msg": "7d4e5ab4-34ca-11ed-b29a-7cc2c61d171e",
"u": {
"_id": "some id",
"username": "svc_site_prod",
"name": "svc_site_prod"
},
"groupable": false,
"_updatedAt": {
"$date": 1663823165902
}
}
It uses t = "au" for added user and "ru" for removed user.
The real user added is present in "msg".
But it only shows the username of user who is added or removed.
I want the full name of this user.
I know I can just make another request to find the user's info by api. But what I want is to get the details in this response.
Edit: the headers of request
{
"msg": "method",
"method": "loadHistory",
"id": "1",
"params": [
"AyzhtTJiE6YG3cnfA",
null,
50,
null
]
}

Cannot retreive virtual card number in test mode via stripe API using Go examples

Trying to follow the example here: https://stripe.com/docs/issuing/cards/virtual
When I add params.AddExpand("number"), no number is returned, yet via the dashboard I was able to see the card numbers. Here's sample code and redacted info for the Req and Resp.
func (ac *appContext) CardRetrieve(id string) *stripe.IssuingCard {
stripe.Key = ac.Config.Stripe.SecretKey
params := stripe.IssuingCardParams{}
params.AddExpand("number")
params.AddExpand("cvc")
ic_num, _ := card.Get(id, &params)
return ic_num
}
Returns:
{
"id": "ic_redacted",
"object": "issuing.card",
"brand": "Visa",
"cancellation_reason": null,
"cardholder": {
"id": "ich_redacted",
"object": "issuing.cardholder",
"billing": {
"address": {
"city": "A Beach",
"country": "US",
"line1": "404 Main St.",
"line2": "Suite #302",
"postal_code": "19001",
"state": "DE"
}
},
"company": null,
"created": 1613338532,
"email": "redacted#notreal.com",
"individual": {
"dob": {
"day": 20,
"month": 10,
"year": 1990
},
"first_name": "User",
"last_name": "Testing",
"verification": {
"document": {
"back": null,
"front": null
}
}
},
"livemode": false,
"metadata": {
},
"name": "User Testing",
"phone_number": "+15165551212",
"requirements": {
"disabled_reason": "under_review",
"past_due": [
]
},
"spending_controls": {
"allowed_categories": [
],
"blocked_categories": [
],
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "active",
"type": "individual"
},
"created": 1613338532,
"currency": "usd",
"exp_month": 1,
"exp_year": 2024,
"last4": "0088",
"livemode": false,
"metadata": {
},
"replaced_by": null,
"replacement_for": null,
"replacement_reason": null,
"shipping": null,
"spending_controls": {
"allowed_categories": null,
"blocked_categories": null,
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "inactive",
"type": "virtual"
}
What confuses me is the documentation found here:
https://stripe.com/docs/issuing/cards/virtual
It says: You can retrieve both the full unredacted card number and CVC from the API. For security reasons, these fields are only available for virtual cards and will be omitted unless you explicitly request them with the expand property. Additionally, they are only available through the Retrieve a card endpoint. That links to the issue card retrieval end point, but the params defined in the virtual cards example references the CardParams{} struct.
No of the examples show what imported module their aliasing for card to exec card.Get, but it stands to reason given the flow of the documentation that this should be IssuingCardParams{} and that the card alias is referencing: "github.com/stripe/stripe-go/issuing/card"
I also find it strange that we're defining params in the example but not passing it into the card.Get()
Edit:
I went digging through the module and it seems like to get the card details you have to call: details, _ := card.Details(id, params) but I get a 404 when trying to call that. The object returned is actually the right object and I see number and cvc, albeit nil.
I get the following error:
2021/02/15 00:33:06 Request error from Stripe (status 404): {"status":404,"message":"Unrecognized request URL (GET: /v1/issuing/cards/ic_redacted/details). Please see https://stripe.com/docs
So it seems you need to include a /v72 in the import:
"github.com/stripe/stripe-go/v72"
The documentation should be updated to show this and the virtual card example for go should also be updated.

Slack create new user

I'm trying to create new users with Slack SCIM API. I've managed to create a new user without password but the invite email was newer sent. I've send following post to https://api.slack.com/scim/v1/Users
{
"schemas": ["urn:scim:schemas:core:1.0",
"urn:scim:schemas:extension:enterprise:1.0"],
"userName": "samplename",
"nickName": "samplename",
"name": {
"familyName": "sample",
"givenName": "name"
},
displayName": "sample name",
"emails": [
{
"value": "sample.name#gmail.com",
"type": "work",
"primary": true
}
],
"userType": "sample",
"title": "sample",
"active":true
}
I can see the user created in the user list but never got the actual invite. (yes I checked spam). Is there even a way for this user to login?

Access control at property level (hiding/showing properties in api response based on the role)

I have a spring-boot based micro-service generated using JHipster.
I am using keycloak as my Auth Server. I could enable Role-based & scope based authorization on my resources(apis).
Now the requirement is: based on the role of the client, I need to restrict the information to send in the response (either mask the attributes or nullify them).
eg:
consider the following api to get the person's profile
/api/person/{id}
{
"name": {
"firstName": "Jack",
"lastName": "Sparrow"
},
"gender": "MALE",
"emails": {
"details": [
{
"emailId": "jack.sparrow#gmail.com"
}
]
},
"phones": {
"details": [
{
"phoneNumber": "1234567890",
"countryCode": "+1"
}
]
},
"addresses": {
"details": [
{
"addressLine1": "aaaaaaaa",
"addressLine2": "bbbbbbb",
"city": "cccccc",
"state": "ddddd",
"country": "South Africa",
"postalCode": "987654"
}
]
},
"photo": "string",
"nationality": "South Africa",
"countryOfResidence": "string",
"active": true,
"createdAt": 1537431339569,
"modifiedAt": 1537436600693,
"createdBy": "admin",
"modifiedBy": "admin"
}
Now, when a person with BASIC role calls this API, the requirement is to show only basic information like:
- name, gender
If he has INTERMEDIATE role then we can send something more than basic but not full information. eg: name, gender, photo, nationality
If he has ADMIN role then we can send the complete information.
Can anyone please let me know What is the best approach to achieve this.
-- Thanks in advance :)

Permission with empty emailAddress

I have one member in a team drive that was suspended, but now it is active.
When I list permissions:
https://www.googleapis.com/drive/v3/files/{drive-id}/permissions?supportsTeamDrives=true&useDomainAdminAccess=true&fields=permissions(type%2Crole%2CemailAddress)
I get:
{
"permissions": [
{
"type": "user",
"emailAddress": "",
"role": "organizer"
},
{
"type": "user",
"emailAddress": "***#***",
"role": "reader"
}
]
}
Is this a correct behavior to return an empty 'emailAddress' for users that were suspended? How can I get user mail in this case?

Resources