So I found a solution to this problem I could of course use the Flares Wizard addon as @Jonas said yet the question was how it can be done with the compositor. This is how it can be done:
- Add in a sphere which should be the sun
- Give it an emission material with a strength of 10
- Navigate to the object properties panel and in the relations ->Change the pass index of the sphere to 1
- Navigate to View layer properties and in the passes-> enable object index (IndexOB)
- Hit Render
- Open up the compositor and use the node setup as shown:



Then you will get this:

PS:If your sphere is too big you will need to tweak the node setup.Likewise adding in a blur node in between can smoothen out that sharp streaks...
This is the rendered result:

If you want just sun glare you can you this node setup:
(Add node near render layers node is not necessary)
Which will get you this effect :

When adding the sun beams node make sure to place the cross in the middle of the sun